Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp date > mysql date format

Status
Not open for further replies.

mthompo

Technical User
Jul 28, 2006
98
0
0
GB
ok have written some script that changes
standard UK date format dd/mm/yyyy to mysql query
format yyyymmdd

Code:
whenstart =date()
motdaynumsql = day(whenstart)
motmonthsql = month(whenstart)
motyearsql = year(whenstart)
'sql start
daysql = motdaynumsql
if daysql < 10 then 
daysql = "0" & daysql
end if
monthsql = motmonthsql
if monthsql < 10 then 
monthsql = "0" & monthsql
end if
'join together
dstartdatesql = motyear & monthsql & daysql

is there a better way of doing this?
 
oops year var was wrong - should read

Code:
whenstart =date()
motdaynumsql = day(whenstart)
motmonthsql = month(whenstart)
motyearsql = year(whenstart)
'sql start
daysql = motdaynumsql
if daysql < 10 then 
daysql = "0" & daysql
end if
monthsql = motmonthsql
if monthsql < 10 then 
monthsql = "0" & monthsql
end if
'join together
dstartdatesql = motyearsql & monthsql & daysql
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top