How can I formt a date in Excel in the form mm/dd that switches t.

G

Guest

I have an application that uses the mm/dd format. However, some of our users
are in the UK and I want to display the date as dd/mm, i.e. it switches
automatically depending on the region. Excel does have a format that switches
depending on the region (it's prefixed with a *) but it's in a form
mm/dd/yyyy and I only want mm/dd.

Anyone know if this can be done?
 
J

Juan Pablo González

I think you need VBA for that. This UDF *should* do it

Function ShowDate(dDate As Date) As String
ShowDate = Format$(dDate, "short date")
Select Case Application.International(xlDateOrder)
Case 0, 1
ShowDate = Application.Substitute(ShowDate, _
Application.International(xlDateSeparator) & Year(Date), _
"")
Case 2
ShowDate = Application.Substitute(ShowDate, _
Year(Date) & Application.International(xlDateSeparator), _
"")
End Select
End Function


Use it like

=ShowDate(A2)

where A2 houses your date.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top