How does VBA interpret Dates?

  • Thread starter Thread starter Greg Glynn
  • Start date Start date
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
 
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.
 
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).
 
Back
Top