Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   month end date (http://www.velocityreviews.com/forums/t120655-month-end-date.html)

=?Utf-8?B?Q3NoYXJwR3V5?= 03-01-2006 03:55 PM

month end date
 
I have a date such as 1/1/2005, how can i get the month end date for that
month?



Brooke 03-01-2006 04:15 PM

Re: month end date
 
What I usually do is chose the 1st day of the following month and then
subtract one day.


"CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
>I have a date such as 1/1/2005, how can i get the month end date for that
> month?
>
>




=?Utf-8?B?Q3NoYXJwR3V5?= 03-01-2006 04:50 PM

Re: month end date
 
do you have a code snippet I could look at that is doing this?

"Brooke" wrote:

> What I usually do is chose the 1st day of the following month and then
> subtract one day.
>
>
> "CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
> news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
> >I have a date such as 1/1/2005, how can i get the month end date for that
> > month?
> >
> >

>
>
>


Ray Booysen 03-01-2006 04:55 PM

Re: month end date
 
Nice and simple, using your 1/1/2005 as the start date:

System.DateTime _myDate = new DateTime(2005,1,1);
_myDate.AddMonths(1);
_myDate.AddDays(-1);

_myDate will now hold 31st of Jan 2005

Regards
Ray

CsharpGuy wrote:
> do you have a code snippet I could look at that is doing this?
>
> "Brooke" wrote:
>
>> What I usually do is chose the 1st day of the following month and then
>> subtract one day.
>>
>>
>> "CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
>> news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
>>> I have a date such as 1/1/2005, how can i get the month end date for that
>>> month?
>>>
>>>

>>
>>



--
Ray Booysen
rj_booysen@rjb.za.net

Adrian Parker 03-01-2006 05:02 PM

Re: month end date
 
how about something like..

MonthEnd= MyDate.AddMonths(1)
MonthEnd = New Date(MonthEnd.Year, MonthEnd.Month, 1).AddDays(-1)

--
Adrian Parker
Ingenuity At Work Ltd

"CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message news:C880002C-3389-4C3D-9E59-2C702F9B8A2D@microsoft.com...
> do you have a code snippet I could look at that is doing this?
>
> "Brooke" wrote:
>
>> What I usually do is chose the 1st day of the following month and then
>> subtract one day.
>>
>>
>> "CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
>> news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
>> >I have a date such as 1/1/2005, how can i get the month end date for that
>> > month?
>> >
>> >

>>
>>
>>




=?Utf-8?B?Q3NoYXJwR3V5?= 03-01-2006 06:37 PM

Re: month end date
 
I just ran this and it gave me 12/31/2004,
unless i showed it wrong
I put the output in a message box

"Ray Booysen" wrote:

> Nice and simple, using your 1/1/2005 as the start date:
>
> System.DateTime _myDate = new DateTime(2005,1,1);
> _myDate.AddMonths(1);
> _myDate.AddDays(-1);
>
> _myDate will now hold 31st of Jan 2005
>
> Regards
> Ray
>
> CsharpGuy wrote:
> > do you have a code snippet I could look at that is doing this?
> >
> > "Brooke" wrote:
> >
> >> What I usually do is chose the 1st day of the following month and then
> >> subtract one day.
> >>
> >>
> >> "CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
> >> news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
> >>> I have a date such as 1/1/2005, how can i get the month end date for that
> >>> month?
> >>>
> >>>
> >>
> >>

>
>
> --
> Ray Booysen
> rj_booysen@rjb.za.net
>


Brooke 03-01-2006 07:05 PM

Re: month end date
 
try this...

using System;



public class MyClass {



private static void GetMonthEnd(System.DateTime dateIn, ref System.DateTime dateOut){

dateIn = dateIn.AddMonths(1);

dateIn = dateIn.AddDays(-1);

dateOut = new System.DateTime(dateIn.Year, dateIn.Month, dateIn.Day);

}



public static int Main(string[] args) {

System.DateTime jan = new System.DateTime(2005,3,1);

System.DateTime endOfJan = new System.DateTime();



GetMonthEnd(jan, ref endOfJan);



Console.WriteLine("Jan: {0}", jan);

Console.WriteLine("endOfJan: {0}", endOfJan);



Console.Write("\nPress any key to continue...");

Console.ReadKey();



return 0;

}

}






"CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message news:C9644FFA-B2E7-4101-8E9C-BCE27E8E56D7@microsoft.com...
>I just ran this and it gave me 12/31/2004,
> unless i showed it wrong
> I put the output in a message box
>
> "Ray Booysen" wrote:
>
>> Nice and simple, using your 1/1/2005 as the start date:
>>
>> System.DateTime _myDate = new DateTime(2005,1,1);
>> _myDate.AddMonths(1);
>> _myDate.AddDays(-1);
>>
>> _myDate will now hold 31st of Jan 2005
>>
>> Regards
>> Ray
>>
>> CsharpGuy wrote:
>> > do you have a code snippet I could look at that is doing this?
>> >
>> > "Brooke" wrote:
>> >
>> >> What I usually do is chose the 1st day of the following month and then
>> >> subtract one day.
>> >>
>> >>
>> >> "CsharpGuy" <CsharpGuy@discussions.microsoft.com> wrote in message
>> >> news:38CE7029-62CF-421E-9666-638F06225DFB@microsoft.com...
>> >>> I have a date such as 1/1/2005, how can i get the month end date for that
>> >>> month?
>> >>>
>> >>>
>> >>
>> >>

>>
>>
>> --
>> Ray Booysen
>> rj_booysen@rjb.za.net
>>



All times are GMT. The time now is 01:02 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.