<% Function FormatDate (dtmDate, strFormat) If dtmDate = "" OR IsNull(dtmDate) OR NOT IsDate(dtmDate) Then FormatDate = dtmDate Exit Function End If '-------------------------------------------------------------------------------------------------------------- ' d The one-digit of the two-digit day. ' dd The two-digit day. Single-digit day values are preceded by a zero. ' ddd The three-character weekday abbreviation. ' dddd The full weekday name. ' h The one-digit or the two-digit hour in 12-hour format. ' hh The two-digit hour in 12-hour format. Single-digit values are preceded by a zero. ' HHH The one-digit or the two-digit hour in 24-hour format. ' HHHH The two-digit hour in 24-hour format. Single-digit values are preceded by a zero. ' n The one-digit or the two-digit minute. ' nn The two-digit minute. Single-digit values are preceded by a zero. ' M The one-digit or the two-digit month number. ' MM The two-digit month number. Single-digit values are preceded by a zero. ' MMM The three-character month abbreviation. ' MMMM The full month name. ' t The one-letter A.M. and P.M. abbreviation (that is, “AM” is displayed as “A”). ' tt The two-letter A.M. and P.M. abbreviation (that is, “AM” is displayed as “AM”). ' y The year is displayed as the last two digits, but with no leading zero for any year that is less than 10. ' yy The last two digits of the year. For example, 1998 would be displayed as “98”. ' yyy The full year. For example, 1998 would be displayed as “1998”. ' p The abbreviation following the numeric date. For example, the "th" in "11th", 12th, 22nd, 23rd, etc. '--------------------------------------------------------------------------------------------------------------- '-- Retrieve values d = DatePart("d", dtmDate) dd = Right("0" + d, 2) dddd = WeekdayName(DatePart("w",dtmDate)) ddd = Left(dddd, 3) If d > 10 AND d < 20 Then p = "th" Else If Right(d,1) = 1 Then p = "st" ElseIf Right(d,1) = 2 Then p = "nd" ElseIf Right(d,1) = 3 Then p = "rd" Else p = "th" End If End If sHour = DatePart("h", dtmDate) HHH = sHour HHHH = Right("0" + HHH, 2) If sHour < 12 Then tt = "AM" ELSE tt = "PM" End If t = Left(tt, 1) If sHour > 12 Then h = sHour - 12 Else h = sHour End If If sHour = 0 OR sHour = 12 Then h = "12" hh = Right("0" + h, 2) n = Trim(DatePart("n", dtmDate)) nn = Right("0" + n, 2) If Len(nn) < 2 Then nn = nn & "0" End If M = DatePart("m", dtmDate) MM = Right("0" + M, 2) MMMM = MonthName(m) MMM = Left(MMMM, 3) syear = DatePart("yyyy", dtmDate) y = Right(syear,2) yy = Right("0" + syear, 2) yyy = Right("000" + syear, 4) '-- Parse format strFormat = Replace(strFormat, "dddd", "\\\\1\\\\") strFormat = Replace(strFormat, "ddd", "\\\\2\\\\") strFormat = Replace(strFormat, "dd", "\\\\3\\\\") strFormat = Replace(strFormat, "d", "\\\\4\\\\") strFormat = Replace(strFormat, "hhhh", "\\\\5\\\\") strFormat = Replace(strFormat, "hhh", "\\\\6\\\\") strFormat = Replace(strFormat, "hh", "\\\\7\\\\") strFormat = Replace(strFormat, "h", "\\\\8\\\\") strFormat = Replace(strFormat, "nn", "\\\\9\\\\") strFormat = Replace(strFormat, "n", "\\\\10\\\\") strFormat = Replace(strFormat, "mmmm", "\\\\11\\\\") strFormat = Replace(strFormat, "mmm", "\\\\12\\\\") strFormat = Replace(strFormat, "mm", "\\\\13\\\\") strFormat = Replace(strFormat, "m", "\\\\14\\\\") strFormat = Replace(strFormat, "p", "\\\\20\\\\") strFormat = Replace(strFormat, "tt", "\\\\15\\\\") strFormat = Replace(strFormat, "t", "\\\\16\\\\") strFormat = Replace(strFormat, "yyy", "\\\\17\\\\") strFormat = Replace(strFormat, "yy", "\\\\18\\\\") strFormat = Replace(strFormat, "y", "\\\\19\\\\") '-- Populate with values strFormat = Replace(strFormat, "\\\\1\\\\", dddd) strFormat = Replace(strFormat, "\\\\2\\\\", ddd) strFormat = Replace(strFormat, "\\\\3\\\\", dd) strFormat = Replace(strFormat, "\\\\4\\\\", d) strFormat = Replace(strFormat, "\\\\5\\\\", hhhh) strFormat = Replace(strFormat, "\\\\6\\\\", hhh) strFormat = Replace(strFormat, "\\\\7\\\\", hh) strFormat = Replace(strFormat, "\\\\8\\\\", h) strFormat = Replace(strFormat, "\\\\9\\\\", nn) strFormat = Replace(strFormat, "\\\\10\\\\", n) strFormat = Replace(strFormat, "\\\\11\\\\", mmmm) strFormat = Replace(strFormat, "\\\\12\\\\", mmm) strFormat = Replace(strFormat, "\\\\13\\\\", mm) strFormat = Replace(strFormat, "\\\\14\\\\", m) strFormat = Replace(strFormat, "\\\\20\\\\", p) strFormat = Replace(strFormat, "\\\\15\\\\", tt) strFormat = Replace(strFormat, "\\\\16\\\\", t) strFormat = Replace(strFormat, "\\\\17\\\\", yyy) strFormat = Replace(strFormat, "\\\\18\\\\", yy) strFormat = Replace(strFormat, "\\\\19\\\\", y) FormatDate = strFormat End Function 'response.write FormatDate("8/23/02","dddd, mmmm ddp hh:nn tt") %>