US to UK date format - something not quite right!!!

adambc

Active Member
Joined
Jan 13, 2020
Messages
376
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I'm back again - apologies!!!

I am using a Date Picker I was pointed to in this Forum which naturally returns the date in US format ...

To accommodate this for UK use, I've written the following code ...

VBA Code:
Private Sub cmdGetDate_Click()

Dim dateVariable As Date
dateVariable = CalendarForm.GetDate

If dateVariable <> 0 Then
txtIncidentDate = dateVariable

If IsDate(Me.txtIncidentDate) Then
Me.txtIncidentDate = Format(Me.txtIncidentDate, "dd/mm/yyyy")

End If

End If

End Sub

... which at first appeared to look OK until I started to select dates where the day is <=12, at which point the US format is retained ...

This has got to be something to do with there being 12 months (hasn't it?), but I'm darned if I can work out a way round it?

Any takers?

Thanks ...

PS; or can anyone point me to a similar (easy to use) Date Picker that works in UK date format?!!!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
It's not the date picker that's causing the problem, it's the fact that VBA is UScentric.
Try
VBA Code:
Private Sub cmdGetDate_Click()

Dim dateVariable As Date
dateVariable = CalendarForm.GetDate
If dateVariable <> 0 Then
   Me.txtIncidentDate.Text = Format(CLng(dateVariable), "dd/mm/yyyy")
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,896
Members
449,194
Latest member
JayEggleton

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