我有这段代码:
Private Function mayIComeIn() As Boolean
With System.Configuration.ConfigurationManager.AppSettings
Dim dStartDate As Date = .Item("StartDate")
Dim dEndDate As Date = .Item("EndDate")
If dStartDate <= Date.Now.Date And Date.Now.Date <= dEndDate Then
Return True
End If
Return False
End With
End Function
这些是web.config中的值(我使用日/月/年作为日期格式):
add key =&#34; StartDate&#34;值=&#34 14/11/2104&#34;
add key =&#34; EndDate&#34;值=&#34 31 /二千零十五分之十二&#34;
使用这些值dStartDate <= Date.Now.Date
返回false。
同样date.Compare(dStartDate, Date.now.Date)
返回1
据我所知,StartDate早于Date.Now,所以我期望比较运算符的返回值为True,date.compare()的返回值为-1 功能。
我遗失了一些东西,或者我应该如何比较这两个日期才知道哪一个更早?