Locked How to get the Last Day of a particular month.

  • Thursday, January 11, 2007 6:34 AM
     
     
    Hi I need to find the last day of a particular month (for example the last day of Feb 2007 is 28). How can I get this. I will be thankful if you help me regarding this.

All Replies

  • Thursday, January 11, 2007 8:04 AM
     
     Answered

    Hi,

    Here is an example:

    int month = 12;
    int
    year = 2006;

    int
    numberOfDays = DateTime.DaysInMonth(year, month);

    DateTime
    lastDay = new DateTime(year, month, numberOfDays);

    Greetz,

    Geert

     

    Geert Verhoeven
    Consultant @ Ausy Belgium

    My Personal Blog

  • Monday, August 15, 2011 1:17 AM
     
     Proposed
    thank you very much.
    Larrix
    • Proposed As Answer by Larrix Monday, August 15, 2011 1:17 AM
    •  
  • Monday, August 15, 2011 6:27 AM
     
     
    Thanks! :)
  • Thursday, May 03, 2012 8:20 PM
     
     

    Awesome!

    Thanks!