0

Is there any VBA function that lets me check a PC date format (regional setting). This is set within the Control Panel -> Region and Language.

Michael

Michaelb88
  • 151
  • 2
  • 6
  • 14

2 Answers2

0

I found this a couple of years back which I use to check the regional date format:

Function DateFormat() As String
  DateFormat = CStr(DateSerial(1999, 1, 2))
  DateFormat = Replace(DateFormat, "1999", "YYYY")
  DateFormat = Replace(DateFormat, "99", "YY")
  DateFormat = Replace(DateFormat, "01", "MM")
  DateFormat = Replace(DateFormat, "1", "M")
  DateFormat = Replace(DateFormat, "02", "dd")
  DateFormat = Replace(DateFormat, "2", "d")
  DateFormat = Replace(DateFormat, MonthName(1), "MMMM")
  DateFormat = Replace(DateFormat, MonthName(1, True), "MMM")
End Function

So on my set-up here, the function returns: dd/MM/YYYY

CLR
  • 11,284
  • 1
  • 11
  • 29
0

You can read this data from the registry at

HKEY_CURRENT_USER\Control Panel\Internationaly\
  • sLongDate represents the long date e.g. dddd, d. MMMM yyyy
  • sShortDate represents the short date e.g. yyyy-MM-dd
Community
  • 1
  • 1
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73