I had a need to change an US date into yyyy/mm/dd and these date formats really irritate me, so this will work for whatever date you need to go from and to.
This is the format.

<% = FormatMediumDate(rs(“date”)) %>

I would make an include file file for this as it can be applied to your entire site with out copying and pasting.

ASP Source Code:

<%
Function FormatMediumDate(DateValue)
Dim strYYYY
Dim strMM
Dim strDD
strYYYY = CStr(DatePart(“yyyy”, DateValue))
strMM = CStr(DatePart(“m”, DateValue))
If Len(strMM) = 1 Then strMM = “0″ & strMM
strDD = CStr(DatePart(“d”, DateValue))
If Len(strDD) = 1 Then strDD = “0″ & strDD
FormatMediumDate = strMM & “/” & strDD & “/” & strYYYY
End Function
%>

The final line can be adjusted to any format you want.

FormatMediumDate = strYYYY & “/” & strMM & “/” & strDD     yyyy/mm/dd

FormatMediumDate = strMM & “/” & strDD & “/” & strYYYY     mm/dd/yyyy

or anything you need.

About Paul Ogier

Paul Ogier has written 202 posts.

Paul Ogier is an IT Guru, Website Developer, and generally a nice guy. He loves code and he loves design.

Incoming search terms for the article: