How does VBA interpret Dates?

G

Greg Glynn

Living and working in Australia, our conventional way to represent
dates is dd/mm/yy. I think our American cousins us mm/dd/yy as their
default.

Is VBA, I get this:

MyDate = #13/12/2007#
? Month(mydate)
12
In this instance, VBA interprets the 2nd qualifier as the month (12),
possibly because 13 cannot be a month.


MyDate = #11/12/2007#
? Month(mydate)
11
In this instance, VBA interprets the 1st qualifier as the month.

This is causing me grief because I have an application that reads text
files and tries to interpret US style dates. Can anyone give me
guidance on the best way to interpret dates?

Thanks in advance.


Greg
 
D

Dave Peterson

Why not just parse the text string into 3 pieces--then recombine it the way you
want:

mydate = dateserial(yearportion, monthportion, dayportion)

Maybe you could use a bunch of left's, right's or mid's to extract each piece.
 
G

Guest

Just to add to Dave's advice, in VBA if you have a date string/text, it will
be interpreted as a US format if possible (mm/dd/yy).
 

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