calendar

hi,
  how do you get the the 1st day and last day of a certain month. from calendar, i will display in textbox1 the first day of the month September. september 1, 2005 and in textbox2 is the last day September 30, 2005 since sept has only 30 number of days. hope someone could help me.


Answer this question

calendar

  • daveky

    is it possible that if i press/select the previous month and next month in my web calendar. the textboxes will display the month, first day and last day of the month.
  • Spaccabit

    The first day of the month is always the 1st, I guess one way to get the last day is to set a datetime to the first day of the next month, then subtract a day and check what the date is.


  • Sammy666

    HI,

    Have you tried using the NumberOfDaysInMonth You can just use that to mark the end of your month, and save that value to a field. You will have to concatenate it to the Month and year to give it the end date for that month


  • Matthew H. Sawyer

    You can use the static method DateTime.DaysInMonth(year, month). This method takes care of leap years, and will return 29 for February 2004.

  • calendar