Date bug

M

Mike Berry

Hi all,

Not sure if this is me or a known problem, and is so if
there is a work around.

I am using a date function as follows:

Format(Date$, "dd, mmm, yyyy")

The month seems to be getting confused if the actual day
is before the 12th. For example today is the 11th July
(11/07) but it is being read as the 7th November (07/11).
When I change my system date to 13th July it reads it
perfectly. I have tried this on other peoples machines
and the error is generated in the same way.

Has anyone come across this and if so is there a solution
to it ?

Thanks,

Mike.
 
P

pfsardella

?Format(Date$, "dd, mmm, yyyy")
11, Jul, 2003

Using Excel 97SR2 on Windows 98SE, I tried your expression in the
Immediate window, and received the correct date.

Maybe the regional settings (set through Control Panel) are different
on my computer.

HTH
Paul
 
T

Tom Ogilvy

It isn't a bug - Excel VBA is US Centric in terms of most date handling.
If you are passing in a string that is dd/mm/yyyy, then you will get the
results you describe with ambiguous dates (where it could be interpreted as
mm/dd/yyyy)

It is best to work with date serial numbers in VBA.

that said, cdate is supposed to observe your regional settings, so try
Format(cdate(Date$), "dd, mmm, yyyy")


Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top