PDA

View Full Version : Solved: Short Date format



Movian
05-27-2009, 08:38 AM
Hey,
is there any way to force the short date (date/time) type to keep leading 0's ?

E.G. at the moment if i put in 09/07/1985 the system will store this as
9/7/1985

However i now need to output dates with a set number of characters so i need to keep the 09/07/1985 format. Alternatively can i just add something to a format statement that will do this? so i can force it just when i output the dates into the files ?

~Edit

Made myself a quick function to do this while i wait for an answer, im sure there is a better way to do this but this should work for now :)

Public Function Standate(shortdate As String)
Dim temp As Variant
temp = Split(CStr(shortdate), "/")
If Len(temp(0)) = 1 Then
temp(0) = "0" & temp(0)
End If
If Len(temp(1)) = 1 Then
temp(1) = "0" & temp(1)
End If
Standate = temp(0) & "/" & temp(1) & "/" & temp(2)
End Function

CreganTur
05-27-2009, 09:03 AM
The short date format is based on the date settings for your comuter. They can be different on different computers. Your function is the best way for continuity.