Get Format date from windows

J

Jose Perdigao

How can I get the default format date in the computer? I mean if the default
date is mm/dd/yyy or d/m/yyyy etc.

Thanks a lot
JP
 
D

Douglas J. Steele

Easiest way is to see what it returns for a date you know.

Dim dtmTestDate As Date
Dim strDate As String

dtmTestDate = DateSerial(2006, 1, 2)
strDate = dtmTestDate

Now examine strDate: is it 2006-01-02, or 1/2/06 or 2/1/2006 or ....

For a more formal approach, see what Randy Birch has at
http://vbnet.mvps.org/code/locale/localedates.htm

Obligatory warning: Randy's site is aimed at VB programmers. There are
significant differences between forms in VB and in Access, so sometimes his
examples don't port directly into Access. In this particular example, Access
will not let you set a control's Text property unless the control has focus,
so all of his assignment statements will fail if you simply copy his code.
To get around this, take off the .Text in the assignment statements.
 
J

Jose Perdigao

It's easy what you said but it is not enough for what I want.

I create a label and when the user open the form, the label should show the
format date. the label should show as the folowing example:

date (mm/dd/yyyy) or
date (dd/mm/yyyy) or
date (d/m/yyyy)

so, the label should show the windows format date.

Thanks
 
D

Douglas J. Steele

Did you check the link I cited? One of the many text boxes Randy's
populating is exactly what you're trying to do.

BTW, my original suggestion expected that you would write some code to parse
what was in strDate.

Dim dtmTestDate As Date
Dim strDate As String

dtmTestDate = DateSerial(2006, 1, 2)
strDate = dtmTestDate

Use InStr to determine where the slashes are (remembering, of course, that
not everyone uses slashes as the date separator: some use - or .) If the
first slash is at position 2, is the first digit 1 (m) or 2 (d)? If the
first slash is at position 2, are the first two digits 01 (mm) or 02 (dd) or
06 (yy)? If the first slash is at position 4, is the first four digits 2006
(yyyy)? and so on.
 
Top