96

VbScript: Number of days in month

Code:

daysInMonth = Day(DateSerial(thisYear, thisMonth + 1, 0))

It adds 1 to the month and uses DateSerial to get a Date representing the 0th day of the following month. That is the last day of the month you entered. The Day function gives you the number of that day, which equals the number of days in the month.

 

3 Comments

 

  1. srinivas April 1, 2010  8:51 am Reply

    Thanx buddy

  2. cursorblock January 14, 2011  1:08 pm Reply

    This is just what we needed. Thanks. :)

  3. Eduardo October 17, 2011  6:13 pm Reply

    Thanks, great piece of code, solved my problem :)

Leave a reply

 

Your email address will not be published.