month end date

Discussion in 'ASP .Net' started by =?Utf-8?B?Q3NoYXJwR3V5?=, Mar 1, 2006.

  1. I have a date such as 1/1/2005, how can i get the month end date for that
    month?
    =?Utf-8?B?Q3NoYXJwR3V5?=, Mar 1, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?Q3NoYXJwR3V5?=

    Brooke Guest

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


    "CsharpGuy" <> wrote in message
    news:...
    >I have a date such as 1/1/2005, how can i get the month end date for that
    > month?
    >
    >
    Brooke, Mar 1, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > >I have a date such as 1/1/2005, how can i get the month end date for that
    > > month?
    > >
    > >

    >
    >
    >
    =?Utf-8?B?Q3NoYXJwR3V5?=, Mar 1, 2006
    #3
  4. =?Utf-8?B?Q3NoYXJwR3V5?=

    Ray Booysen Guest

    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" <> wrote in message
    >> news:...
    >>> I have a date such as 1/1/2005, how can i get the month end date for that
    >>> month?
    >>>
    >>>

    >>
    >>



    --
    Ray Booysen
    Ray Booysen, Mar 1, 2006
    #4
  5. 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" <> wrote in message news:...
    > 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" <> wrote in message
    >> news:...
    >> >I have a date such as 1/1/2005, how can i get the month end date for that
    >> > month?
    >> >
    >> >

    >>
    >>
    >>
    Adrian Parker, Mar 1, 2006
    #5
  6. 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" <> wrote in message
    > >> news:...
    > >>> I have a date such as 1/1/2005, how can i get the month end date for that
    > >>> month?
    > >>>
    > >>>
    > >>
    > >>

    >
    >
    > --
    > Ray Booysen
    >
    >
    =?Utf-8?B?Q3NoYXJwR3V5?=, Mar 1, 2006
    #6
  7. =?Utf-8?B?Q3NoYXJwR3V5?=

    Brooke Guest

    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" <> wrote in message news:...
    >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" <> wrote in message
    >> >> news:...
    >> >>> I have a date such as 1/1/2005, how can i get the month end date for that
    >> >>> month?
    >> >>>
    >> >>>
    >> >>
    >> >>

    >>
    >>
    >> --
    >> Ray Booysen
    >>
    >>
    Brooke, Mar 1, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    911
    Dale King
    May 15, 2006
  2. Michal Maciejczak
    Replies:
    1
    Views:
    1,980
    Matthias Kaeppler
    Apr 23, 2005
  3. Bill
    Replies:
    10
    Views:
    732
    Fulvio
    Apr 13, 2006
  4. Replies:
    1
    Views:
    445
    Steve W. Jackson
    Dec 22, 2006
  5. Mufasa
    Replies:
    0
    Views:
    399
    Mufasa
    Sep 5, 2008
Loading...

Share This Page