View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Weekday Function Returns Wrong Number

On Mon, 18 Sep 2006 13:29:09 -0600, "Thomas M."
wrote:

Excel 2003

I created the following very simple subroutine as a test.

Sub CheckDay()
MsgBox Weekday(Today)
End Sub

The message box displays the number 7. Unfortunately, today is Monday and
the message box should display the number 2. I've verified that my system
time and date are correct. It seems to me that I've run into this before
and that the fix is easy, but I'm just drawing a complete blank and searches
of the on-line help have been fruitless. Can anyone tell me how to make
this simple subroutine return the correct number for the day of the week?

--Tom


In addition to what others have written, "Today" is not a valid keyword in VBA.
So it evaluates to Zero in the expression in your subroutine.

The ZEROth day of the calendar, in VBA, is 30 Dec 1899 which is a Saturday.


--ron