Determining the day of the week
Posted: Fri May 19, 2006 7:31 pm
Here's how to determine the day of the week, given the current date. Note that you will need to write your own script to determine the values of MM2, DD and YY. Hope this helps you. (Please note that this only works for dates between the year 2000 and 2099)
DD = day of current date
MM2 = month of current date (March = 3, November = 11, etc)
YY = last two digits of the current year (2006 = 6, etc)
Values for d:
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
DD = day of current date
MM2 = month of current date (March = 3, November = 11, etc)
YY = last two digits of the current year (2006 = 6, etc)
Code: Select all
var MM;
case(MM2)
1: MM := 1;
2: MM := 4;
3: MM := 4;
4: MM := 0;
5: MM := 2;
6: MM := 5;
7: MM := 0;
8: MM := 3;
9: MM := 6;
10: MM := 1;
11: MM := 4;
12: MM := 6;
endcase
var a := Cint(YY / 4) + DD + MM + 6 + YY;
var b := a / 7;
var c := Cint(a - (7 * b));
var d;
case(c)
1: d := 0;
2: d := 1;
3: d := 2;
4: d := 3;
5: d := 4;
6: d := 5;
0: d := 6;
endcase
return d;
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday