Hi,
I have two questions:
1) Is It Possible to Retrieve The Date Format on a computer?
If so then how?
2) Which Date Format does MS Access Database Use
Printable View
Hi,
I have two questions:
1) Is It Possible to Retrieve The Date Format on a computer?
If so then how?
2) Which Date Format does MS Access Database Use
for VB and access there's one format for date and Time called a DateTime in Access or a Date in VB, you can convert string to a date using the CDate() Function, you can retrieve the current date by using the Date keyword.
Code:Dim dteToday as Date
dteToday = Date
1. You can use GetLocaleInfo to get date formats:
2. Access stores date as a long date format. So even if you setup a specific date format on that field, it still saves the date in the long format.Code:Option Explicit
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 Const LOCALE_USER_DEFAULT = &H400
Private Const LOCALE_SSHORTDATE = &H1F ' short date format string
Private Const LOCALE_SLONGDATE = &H20 ' long date format string
Private Sub Form_Load()
Dim strLocale As String
Dim lngRet As Long
Dim strMsg As String
'Get short date format
strLocale = Space(255)
lngRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, strLocale, Len(strLocale))
strLocale = Left(strLocale, lngRet - 1)
strMsg = "Short Date Format: " & strLocale
'Get long date format
strLocale = Space(255)
lngRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, strLocale, Len(strLocale))
strLocale = Left(strLocale, lngRet - 1)
strMsg = strMsg & vbCrLf & "Long Date Format: " & strLocale
MsgBox strMsg
End Sub