# VB get System Date Format



## Russell Morton (Apr 2, 1999)

Hi, this should be easy, how do I determine if the system date format is DD/MM/YYYY or MM/DD/YYYY.


----------



## AbvAvgUser (Oct 3, 2002)

I had it figured out some time back but don't remember now. Although as far as I am remember, my method was not full proof and there was no way to tell a date format on days like 1st Jan, 2nd Feb, 3rd Mar, etc.

But still just give me a day or two and I will try to find it out.


----------



## TimCottee (Oct 10, 2001)

```
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long

Private Const LOCALE_SSHORTDATE = &H1F

Private Sub Command1_Click()
    Dim strResult As String
    Dim strInfo As String * 10
    lngIdentifier = GetUserDefaultLCID()
    lngResult = GetLocaleInfo(lngIdentifier, LOCALE_SSHORTDATE, strInfo, 10)
    strResult = "Short Date String = " & strInfo & vbLf
    MsgBox Replace(strResult, Chr(0), "")
End Sub
```
Should do it.


----------



## Russell Morton (Apr 2, 1999)

Thanks again all.

This seems to work also

If Month("01-02-03") = 1 Then
strFormat ="MM/DD/yyyy" 
else Month("01-02-03") = 2 Then
strFormat = "DD/MM/yyyy"
End if


----------

