WebsiteGear Logo Log In
New User? Sign Up
About | Contact | FAQ
Home Discussion Forums Website Development ASP, VB & .NET
New Post New Post | Report Abuse Report Abuse


Function to convert VB date to MySQL date
Post by websitegear 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


Submit To Slashdot Slashdot | Submit To Digg.com Digg | Save in del.icio.us Del.icio.us | Submit To Reddit Reddit
REPLIES & COMMENTS Post a Reply
LATEST FORUM POSTINGS
Nav How to develop a Flxexible Web Design | Mar 5, 2013
Nav Website comments on updates / improvements please | Feb 28, 2013
Nav WebsiteGear Introduces Unlimited Web Survey Plan | Dec 4, 2012
Nav HTML TAGGING PROJECT CONVERSION 100% QUALITY | Nov 28, 2012
Nav Backup Your Files, Photos, Music online For Free | Nov 25, 2012
Nav 5 common link building mistakes | Aug 27, 2011
Nav How to convert psd into html? | Jan 15, 2011
Nav How to choose the right PHP Framework for web deve | Jan 12, 2011
FORUM SEARCH

FEATURED NEWS | POPULAR NEWS
Submit News | View More News View More News