devxlogo

Get Date Format String

Get Date Format String

There is no native function for returning the current date format string. Here’s a simple function that calls the GetLocaleInfo API in order to retrieve the short date format string:

     Private Const LOCALE_SSHORTDATE = &H1F    Private Const LOCALE_USER_DEFAULT As Long = &H400    Private Declare Function GetLocaleInfo Lib "KERNEL32" _        Alias "GetLocaleInfoA" (ByVal lLocale As Long, _            ByVal lLocaleType As Long, _            ByVal sLCData As String, _            ByVal lBufferLength As Long) As Long    Public Function GetDateFormat() As String    Dim lReturn As Long    Dim sBuffer As String    Dim lBufferLength As Long        lBufferLength = 128        sBuffer = String$(lBufferLength, 0)        lReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, _LOCALE_SSHORTDATE, sBuffer, lBufferLength)        If lReturn > 0 Then            GetDateFormat = Left$(sBuffer, lReturn - 1)        End If    End Function
See also  How to Avoid Money Transfer Scams  
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist