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
04/26/2017

thanks Bubba!

Jake asp vbscript date formatmediumdate formatdatelong howto reference


Back To Top
© 1998 - 2017 psacake.com | My3C's

Version 7.2 | Advertise on this site