Format Medium Date

The FormatMediumDate function returns mm/dd/yyyy, unlike (FormatDateTime(Now(),2) which only returns mm/dd/yy.

Syntax: mediumdate = FormatMediumDate(datevar) Example Usage:

<% = FormatMediumDate(rs("date")) %>
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 
%>
Result
03/19/2024

thanks Bubba!

Jake asp vbscript date formatmediumdate formatdatelong howto reference


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site