weekday as number

Hi
In Tiger this works fine:

weekday of (current date) as number

Returns 0 for sunday, 1 for Monday, …
Does it work in 10.3 too? If not, how do I get the number of the weekday

this will work in both 10.4 and 10.3

try
	set weekdayToday to the weekday of (current date) as number
on error
	set weekdayToday to the weekday of (current date)
	set weeklist to {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}
	repeat with i from 1 to 7
		if weekdayToday is equal to item i of weeklist then set weekdayToday to i - 1
	end repeat
end try
weekdayToday

The ‘weekday as number’ coercion was introduced with Tiger and doesn’t work on earlier systems.

If you’ve got the actual date to hand, as opposed to just the weekday, you can do it like this:

set theDate to (current date)
set weekdayNum to ((theDate - (date "Sunday 5 January 1000 00:00:00)) mod weeks) div days + 1

If you prefer to number weekdays starting from the Monday, you can change the subtracted date to date “Monday 6 January 1000 00:00:00”.