
days in a given month.
Hi all,<BR><BR>how do I know how much days are in a given month and which date is which day??<BR><BR>let's say I get this month (july) as the query, I want to know the number of days (31) and which day is the first of july.<BR><BR>I want to create a calender so I knida need this info..<BR><BR>thanks a lot.

RE: days in a given month.
Well, you always know how many days are in the month, with the exception of Feb. Hard code it.<BR><BR>For days, check the docs:<BR><BR>foistOvDaMonf = WeekdayName(Weekday(#7/1/2004#))

RE: days in a given month.
first of all thanks for the quick response...<BR>the thing with the first day of the month works great, thanks.<BR><BR>about the number of days per month, yes I do know how much days are in any month but there's no way to get that info with out using an array or a bunch of "if"s????

RE: days in a given month.
I would imagine there are thousands of examples out there if you did a quick search... but for JS you could simply do:<BR><BR>function totalDays(m){<BR> switch (m){<BR> case 0: //js months start at 0<BR> return 31;<BR> case 1:<BR> //do some checking here for a leap year... I *think*<BR> //you'll return 20 if the year is evenly divisible by 4 and<BR> //not 100? Or something like that...<BR> case 3:<BR> return 30;<BR> }<BR>}<BR><BR><BR>and so on....

Here's the leaps
Leap Year Calculation <BR><BR><BR>1. Years divisible by four are leap years, unless...<BR>2. Years also divisible by 100 are not leap years, except...<BR>3. Years divisible by 400 are leap years.<BR><BR> <BR><BR>So not hard to code...<BR> if ((y % 4 == 0)) && ((y % 100 != 0)  (y % 400 == 0)))<BR><BR>should work. Untested.

Triple blech...
VBScript has a function created JUST for this purpose!<BR><BR>DateSerial( )<BR><BR><%<BR>dt = ... input any date ...<BR><BR>NumberOfDays = DateSerial( Year(dt), Month(dt)+1, 0 )<BR>WeekdayOfFirstOfMonth = Weekday( DateSerial( Year(dt), Month(dt), 1 ) )<BR>%><BR><BR>Or WeekdayName(WeekDay( ... ) ) if you want text form.<BR><BR>Yes, it handles any month in any year, even leap years.<BR><BR>

RE: days in a given month.
yeah well, that's what I thought....<BR>I'm using vbscript but the idea is the same.<BR><BR>hoped that there's a function in asp that will give me the answer.<BR><BR>thanks.

RE: I think you forgot something??
One more step perhaps:<BR>NumberOfDays = Day(DateSerial( Year(dt), Month(dt)+1, 0 )) <BR>

RE: days in a given month.

I assumed client side JS <nm>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

