
Calendar algorithm
I'm making an ASP calendar and I can't figure out how to get the first day of the month start on the correct day of the week. Like April 1 was on a Sunday, March 1 was on a Thursday, and May 1 will be on a Tuesday. There has to be some sort of algorithm to do this. I looked on the internet and some said they got an alogrithm out of a book called the Rainbow Mathematics Encyclopedia but I can't find that book. The person who gave the title must have been wrong because I can't find that book anywhere on the internet. Thanks for the help.

I wrote demo on our Web site...
http://www.chilisoft.com/caspsamp/calendar.asp<BR><BR>It's pretty clear and easy to use. But be kind! I think it was the first ASP page I ever wrote, so it may not be real efficient.<BR><BR>But I also provide a version that is all browserside (in JavaScript code) on my "home" site: <BR>http://www.ClearviewDesign.com/NEWBIE<BR><BR>

Oh, blech! Time to rewrite!
All this code:<BR><BR><BR> '<BR> ' figure out number of days in the month<BR> '<BR> If ( themonth = 2 ) Then<BR> ' February  assume 28 day month<BR> daysInMonth = 28<BR> ' But then see if should be 29 day<BR> If theyear = ( 4 * Int( theyear / 4 ) ) Then<BR> daysInMonth = 29<BR> ' Every 4 years is a leap year...EXCEPT<BR> If theyear = ( 100 * Int( theyear / 100 ) ) Then<BR> daysInMonth = 28<BR> ' Every 100 years is NOT a leap year...EXCEPT<BR> If theyear = ( 400 * Int( theyear / 400 ) ) Then<BR> ' Every 400 years IS a leap year<BR> daysInMonth = 29<BR> End If<BR> End If<BR> End If<BR> Else<BR> If ( themonth=4 or themonth=6 or themonth=9 or themonth=11 ) Then<BR> daysInMonth = 30<BR> Else<BR> daysInMonth = 31 <BR> End If<BR> End If<BR><BR>Can be replace with just this:<BR><BR> daysInMonth = Day( DateSerial( theYear, theMonth+1, 0 ) )<BR><BR>Really! Honest. See, I've learned a little bit since then.<BR><BR>

can't change history
Ufda,<BR><BR>Good to know even you wrote code like that.<BR><BR>hehe.<BR><BR>even superman had kryptonite

Unless you write the history book...
But too true!<BR><BR>I was conditioned to using C/C++/Pascal, and none of them have the handy Date functions that VBS has! <BR><BR>DateSerial is a woefully overlooked function! I had to implement it for the ChiliSoft version of ASP (writing in C++, that is), and it was a pain! But the results are well worth it in the end!
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

