Function to convert VB date to MySQL date
Post by webgear on
Jul 31, 2006 2:51:55 AM CST
Here is the code to convert a VB date to MySQL format.
function toSQLDate(dateInput)
strYear = CStr(Year(dateInput)) strMonth = CStr(Month(dateInput)) strDay = CStr(Day(dateInput)) strHour = CStr(Hour(dateInput)) strMinute = CStr(Minute(dateInput)) strSecond = CStr(Second(dateInput))
If Len(strhour) = 1 Then strhour = "0" & strhour ElseIf Len(strhour) = 0 Then strhour = "00" End If
If Len(strMinute) = 1 Then strminute = "0" & strMinute ElseIf Len(strMinute) = 0 Then strminute = "00" End If
If Len(strSecond) = 1 Then strsecond = "0" & strSecond ElseIf Len(strSecond) = 0 Then strsecond = "00" End If
If Len(strDay) = 1 Then strday = "0" + strDay ElseIf Len(strDay) = 0 Then strday = "00" End If If Len(strMonth) = 1 Then strmonth = "0" & strMonth ElseIf Len(strMonth) = 0 Then strmonth = "00" End If
toSQLDate = strYear + "-" + strmonth + "-" + strday + " " + strhour + ":" + strminute + ":" + strsecond end function
|
|
|
|
|
|
 |
|
|
|
|
 |
|
|