Using ASP classic, I need to somehow compare two dates with each other. How can I do this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Date1 = #rs["date"]#
Date2 = #12/1/2009#
If DateDiff("d", Date1, Date2) > 1 Then
response.write "This date is before 12/1/2009"
Else
response.write "This date is after 12/1/2009"
End If
HTH
回答2:
If Date1 > Date2 Then
' Date1 occurred after Date 2
End If
Use >
, <
and =
like comparing numbers (and >=
, <=
and <>
too). Smaller dates are more historic.
This of course assumes that Date1
and Date2
are actually Date or DateTime objects. If they aren't, you'll need to convert them to Date objects first using CDate()
.