asp日付補完
2103 ワード
<%
Function ShowTime(DateAndTime, Format)
On Error Resume Next
Dim yy,y, m, d, h, mi, s, strDateTime
showtime = DateAndTime
If Not IsNumeric(Format) Then Exit Function
If Not IsDate(DateAndTime) Then Exit Function
yy = CStr(Year(DateAndTime))
y = Mid(CStr(Year(DateAndTime)),3)
m = CStr(Month(DateAndTime))
If Len(m) = 1 Then m = "0" & m
d = CStr(Day(DateAndTime))
If Len(d) = 1 Then d = "0" & d
h = CStr(Hour(DateAndTime))
If Len(h) = 1 Then h = "0" & h
mi = CStr(Minute(DateAndTime))
If Len(mi) = 1 Then mi = "0" & mi
s = CStr(Second(DateAndTime))
If Len(s) = 1 Then s = "0" & s
Select Case Format
Case "1"
strDateTime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case "2"
strDateTime = yy & m & d & h & mi & s
Case "3"
strDateTime = yy & m & d & h & mi
Case "4"
strDateTime = yy & " " & m & " " & d & " "
Case "5"
strDateTime = m & "-" & d
Case "6"
strDateTime = m & "/" & d
Case "7"
strDateTime = m & " " & d & " "
Case "8"
strDateTime = y & " " & m & " "
Case "9"
strDateTime = y & "-" & m
Case "10"
strDateTime = y & "/" & m
Case "11"
strDateTime = y & "-" & m & "-" & d
Case "12"
strDateTime = y & "/" & m & "/" & d
Case "13"
strDateTime = yy & "." & m & "." & d
Case "14"
strDateTime = yy & "-" & m & "-" & d
Case Else
strDateTime = DateAndTime
End Select
showtime = strDateTime
End Function
%>
<%=ShowTime(Rs("time"),14)%>