View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Wierd Bug with Format Date VBA???

I'm not quite sure I understand what you're doing, but

wkday = format(11,"ddd")
isn't formatting the 11th of this month. It's formatting the 11th day after day
0. (Day 0 in VBA is 12/30/1899).

If you try:
(with theday = 11)
MsgBox Format(theday, "mm/dd/yyyy")
You'll see 01/10/1900

Option Explicit
Sub stuff()
Dim TheDate As Date
Dim TheMonth As Long
Dim TheDay As Long
Dim TheYear As Long
Dim WkDay As String

TheDate = Date
'not sure why you want the next two lines
'TheMonth = Month(TheDate)
'TheDay = Day(TheDate)
WkDay = Format(TheDate, "ddd")
MsgBox WkDay
End Sub




wrote:

sub stuff()
theDate = Format(Now,"mm-dd-yy")
themonth = Month(theDate)
theDay = Day(theDate)
wkday = Format(theDay, "ddd")
end sub

.... for some reason when i use the Format() function, it takes the day
before. Is there an option statement that I am missing or something?
The first format string returns the correct day, but the second one
returns the previous day. Am i missing an option statement?


--

Dave Peterson