matthewkhoury
asked on
Type mismatch: 'Format'
Why does this:
Response.Write Format(Date(),"yyyymmdd")
Return this:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Format'
My objective is to take a datetime field from SQL Server and convert that date to the following format on, YYYYMMDD.
Thanks in advance...
Response.Write Format(Date(),"yyyymmdd")
Return this:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Format'
My objective is to take a datetime field from SQL Server and convert that date to the following format on, YYYYMMDD.
Thanks in advance...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops sM should be sD in this line:
if Len(sD) = 1 then sD = "0" & sD
if Len(sD) = 1 then sD = "0" & sD
and test it with:
Response.write formatDateYMD(Date())
Response.write formatDateYMD(Date())
function formatDateYMD(sDate)
dim sY, sM, sD
sY = Year(sDate)
sM = Month(sDate)
sD = Day(sDate)
if Len(sM) = 1 then sM = "0" & sM
if Len(sD) = 1 then sM = "0" & sD
formatDateYMD = sY & sM & sD
end function