Find if Excel is using US or UK date format

WaqasTariq

Board Regular
Joined
Jun 26, 2012
Messages
58
Office Version
  1. 365
Hi,
Is there anything in Excel VBA that will identify the current date format of Excel?

I am writing a macro and the people who will use it will be in the US and UK. I do not want to create two different solutions. Is there a way I can know what date format Excel is using so that I can base my rest of the code on that information?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You can use the Application.International property (Excel) with xlDateOrder

For example

VBA Code:
Option Explicit

Sub Sample()
    Dim DateOrderType As Integer
    
    DateOrderType = Application.International(xlDateOrder)
    
    Select Case DateOrderType
        Case 0: Debug.Print "M-D-Y"
        Case 1: Debug.Print "D-M-Y"
        Case 2: Debug.Print "Y-M-D"
    End Select
End Sub
 
Upvote 0
Solution
You can use the Application.International property (Excel) with xlDateOrder

For example

VBA Code:
Option Explicit

Sub Sample()
    Dim DateOrderType As Integer
   
    DateOrderType = Application.International(xlDateOrder)
   
    Select Case DateOrderType
        Case 0: Debug.Print "M-D-Y"
        Case 1: Debug.Print "D-M-Y"
        Case 2: Debug.Print "Y-M-D"
    End Select
End Sub
Thank you, that worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top