There was an error in a part of the date format. [ Expression (if known) = ]
I am trying to save date in my database' datetime field. My variable catches date as
vrDteTimePprBgn As Date = Today.Date
then I save it as drNewRowMCQsAns.Item("DTE") = vrDteTimePprBgn
At runtime, I get error There was an error in a part of the date format. [ Expression开发者_运维百科 (if known) = ] Please advise. Thanks
Try this
Public Function SQLDate(ByVal DT As Date)
Dim FDay As Byte = DT.Day
Dim FMonth As Byte = DT.Month
Dim FYear As Integer = DT.Year
Dim FHour As Byte = DT.Hour
Dim FMin As Byte = DT.Minute
Dim FSec As Byte = DT.Second
SQLDate = FYear & "-" & FMonth & "-" & FDay & " " & FHour & ":" & FMin & ":" & FSec
End Function
The resul is in String format but it works sorry for my bad English
精彩评论