Like somuch.com on Facebook Share somuch.com on Facebook somuch.com on Twitter Reddit LinkedIn Pinterest
Newest Tips & Tricks...

Home :: Tips & Tricks :: Active Server Pages

Date Function to Add a Leading Zero

This function Adds a leading zero to the month and day in a date (09/09/2001). You may have to make changes depending on your server time format and region.


Function FixDate()

Dim DateArray, CurrMonth, CurrDay
DateArray = Split(Date(), "/")
CurrMonth = DateArray(0)
If CurrMonth < 10 Then
CurrMonth = "0" & DateArray(0)
End If

CurrDay = DateArray(1)
If CurrDay < 10 Then
CurrDay = "0" & DateArray(1)
End If

FixDate = CurrMonth & "/" & CurrDay & "/" & DateArray(2)

End Function

Source: Chuck Dearbeck

Recommended Links...