<%
Function formatDateTime(in_Date, strFormat)
Dim aryMonth(12)
Dim strDay, strMonth, strYear, strHour, strMinute, strSecond, strAMPM
Dim temp
aryMonth(0) = "Nothing"
aryMonth(1) = "January"
aryMonth(2) = "Feburary"
aryMonth(3) = "March"
aryMonth(4) = "April"
aryMonth(5) = "May"
aryMonth(6) = "June"
aryMonth(7) = "July"
aryMonth(8) = "August"
aryMonth(9) = "September"
aryMonth(10) = "October"
aryMonth(11) = "November"
aryMonth(12) = "December"
If IsNull(in_Date) _
Or in_Date = "" _
Or IsNull(strFormat) _
Or strFormat = "" Then
temp = ""
Else
Select Case strFormat
Case "MON_DD,_YYYY"
strDay = Day(in_Date)
strMonth = aryMonth(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strMonth & " " & strDay & ", " & strYear
Case "MM/DD/YYYY"
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strMonth & "/" & strDay & "/" & strYear
Case "MM/DD/YYYY HH24:MI:SS"
strSecond = formatTo2Digit(Second(in_Date))
strMinute = formatTo2Digit(Minute(in_Date))
strHour = formatTo2Digit(Hour(in_Date))
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strMonth & "/" & strDay & "/" & _
strYear & " " & strHour & ":" & strMinute & ":" & strSecond
Case "MM/DD/YYYY HH:MI:SS AM/PM"
strSecond = formatTo2Digit(Second(in_Date))
strMinute = formatTo2Digit(Minute(in_Date))
strHour = formatTo2Digit(formatHourIn12(Hour(in_Date)))
strAMPM = amORpm(Hour(in_Date))
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
If CInt(strHour) = 0 _
And CInt(strMinute) = 0 _
And CInt(strSecond) = 0 Then
temp = strMonth & "/" & strDay & "/" & strYear & " 12:00:00 AM"
Else
temp = strMonth & "/" & strDay & "/" & strYear & " " & _
strHour & ":" & strMinute & ":" & strSecond & " " & strAMPM
End If
Case "YYYYMMDDHHNNSS"
strSecond = formatTo2Digit(Second(in_Date))
strMinute = formatTo2Digit(Month(in_Date))
strHour = formatTo2Digit(Hour(in_Date))
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strYear & strMonth & strDay & strHour & strMinute & strSecond
Case "YYYY.MM.DD.HH.NN.SS"
strSecond = formatTo2Digit(Second(in_Date))
strMinute = formatTo2Digit(Month(in_Date))
strHour = formatTo2Digit(Hour(in_Date))
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strYear & "." & strMonth & "." & strDay & _
"." & strHour & "." & strMinute & "." & strSecond
Case "YYYY.MM.DD"
strDay = formatTo2Digit(Day(in_Date))
strMonth = formatTo2Digit(Month(in_Date))
strYear = formatYearTo4Digit(Year(in_Date))
temp = strYear & "." & strMonth & "." & strDay
Case Else
End Select
End If
formatDateTime = temp
End Function
|