1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VB get System Date Format

Discussion in 'Software Development' started by Russell Morton, May 7, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. Russell Morton

    Russell Morton Thread Starter

    Joined:
    Apr 2, 1999
    Messages:
    136
    Hi, this should be easy, how do I determine if the system date format is DD/MM/YYYY or MM/DD/YYYY.
     
  2. AbvAvgUser

    AbvAvgUser

    Joined:
    Oct 3, 2002
    Messages:
    2,281
    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.
     
  3. TimCottee

    TimCottee

    Joined:
    Oct 10, 2001
    Messages:
    186
    Code:
    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.
     
  4. Russell Morton

    Russell Morton Thread Starter

    Joined:
    Apr 2, 1999
    Messages:
    136
    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
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/132503

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice