Calculate Day of Week By Date

Squintz

Senior Member
I found this while searching and since alot of us like to play with time and dates and stuff i figured i would post it here.

Code:
To calculate the day on which a particular date falls, the following
algorithm may be used (the divisions are integer divisions, in which
remainders are discarded; % means all we want is the remainder):
 
a = (14 - month) / 12
y = year - a
m = month + 12*a - 2
For Julian calendar: d = (5 + day + y + y/4 + (31*m)/12) % 7
For Gregorian calendar: d = (day + y + y/4 - y/100 + y/400 + (31*m)/12) % 7
 
The value of d is 0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc.

I got it from this site: http://www.smart.net/~mmontes/ushols.html
 
Squintz,
It's much easier than that.

Code:
SWeekDayName = WeekdayName(Weekday(Now()))

or
Code:
sDate = "1/3/05"
SWeekDayName = WeekdayName(Weekday(sDate))
 
Back
Top