【发布时间】:2012-06-12 17:36:37
【问题描述】:
上次保存在数据库中的日期是: 2012 年 6 月 13 日下午 12:27:30
在我的 DateTime Now 中是: 2012 年 6 月 13 日上午 01:27:57
但是,当我执行这个函数时,它总是说: "日期已手动修改,请设置为有效日期时间"
但是,DateTime Now 不小于我数据库中的日期。怎么了?
这是代码,请更正,
Private lastdate As DateTime
Private Sub GetDBdate()
...
Dim ss As String
Dim sc As New SQLiteCommand
ss = "select dtime from dincome order by dtime desc limit 1"
sc = New SQLiteCommand(ss, mycon)
lastdate = CDate(sc.ExecuteScalar)
End Sub
Private Function CheckValidDate() As Boolean
Dim dtnow As DateTime = DateTime.Now
If dtnow < lastdate Then
Return False
End If
Return True
End Function
Private Sub Button_Click
If Not CheckValidDate() Then
label1.Text = "Date has been manually modified, Please Set to Valid DateTime"
Exit Sub
End If
...
...
Exit Sub
【问题讨论】:
-
但是 01:27 AM(现在)小于 12:27 PM(LastDate),因此无效。
-
@Nico Schertler,是的,你说得对,我没看到,但是我的数据库的日期是 2012 年 6 月 13 日,而日期是 2012 年 6 月 12 日下午,我会像布莱恩比查姆说的那样看。谢谢