number of days in a given month

# Thread: number of days in a given month

1. zig Guest

## number of days in a given month

how do you find number of days in a given month.

2. sm549 Guest

## one way

You could create a date using the first day of the modulo next month and subtract a day.

3. doubtfire Guest

## RE: don't follow,need code

i&#039m flummoxed.i&#039m a newbee.can somebody get more explicit

4. Junior Member
Join Date
Dec 1969
Posts
11

## RE: don't follow,need code

You can find the code along with explanation at the URL http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=43

5. Senior Member
Join Date
Dec 1969
Posts
150

## RE: number of days in a given month

Hi,<BR><BR>Call the function findDay passing year and month as an argument.<BR><BR>&#060;SCRIPT LANGUAGE=javascript&#062;<BR>&#060;!--<BR>function makeArray(n) {<BR> for (var i = 1; i &#060;= n; i++) {<BR> this[i] = 0<BR> } <BR> return this<BR>}<BR><BR>var daysInMonth = makeArray(12);<BR>daysInMonth[1] = 31;<BR>daysInMonth[2] = 29; // must programmatically check this<BR>daysInMonth[3] = 31;<BR>daysInMonth[4] = 30;<BR>daysInMonth[5] = 31;<BR>daysInMonth[6] = 30;<BR>daysInMonth[7] = 31;<BR>daysInMonth[8] = 31;<BR>daysInMonth[9] = 30;<BR>daysInMonth[10] = 31;<BR>daysInMonth[11] = 30;<BR>daysInMonth[12] = 31;<BR>function daysInFebruary (year)<BR>{ // February has 29 days in any year evenly divisible by four,<BR> // EXCEPT for centurial years which are not also divisible by 400.<BR> return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) &#124&#124 (year % 400 == 0) ) ) ? 29 : 28 );<BR>}<BR>function findDay (year, month)<BR>{ <BR> <BR> var intYear = parseInt(year);<BR> var intMonth = parseInt(month);<BR> <BR> if ((intMonth == 2) ) <BR> return daysInFebruary(intYear); <BR> else<BR> return daysInMonth[intMonth];<BR> <BR> <BR>}<BR>//--&#062;<BR>&#060;/SCRIPT&#062;

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•