Hi everyone.
I have this date in this format input : Sat, 13 Mar 2010 18:15:00 CST
I need this output: 2010-03-13
Can someone help me?
Thanks in advance.
Chevy
| SitePoint Sponsor |
Hi everyone.
I have this date in this format input : Sat, 13 Mar 2010 18:15:00 CST
I need this output: 2010-03-13
Can someone help me?
Thanks in advance.
Chevy




myDate = split ("Sat, 13 Mar 2010 18:15:00 CST" , " " )
if Lcase(left(trim(MyDate(2)),3)) = "jan" then Mnth = 1
if Lcase(left(trim(MyDate(2)),3)) = "feb" then Mnth = 2
if Lcase(left(trim(MyDate(2)),3)) = "mar" then Mnth = 3
'...repeat 4-12
response.write MyDate(3) & "/" & Mnth & "/" & MyDate(1)
thanks x your help, but your code:
Print this 2010--13Code:<% myDate = split ("Sat, 13 Mar 2010 18:15:00 CST" , " " ) if Lcase(left(trim(MyDate(2)),3)) = "Jan" then Mnth = 01 if Lcase(left(trim(MyDate(2)),3)) = "Feb" then Mnth = 02 if Lcase(left(trim(MyDate(2)),3)) = "Mar" then Mnth = 03 if Lcase(left(trim(MyDate(2)),3)) = "Apr" then Mnth = 04 if Lcase(left(trim(MyDate(2)),3)) = "May" then Mnth = 05 if Lcase(left(trim(MyDate(2)),3)) = "Jun" then Mnth = 06 if Lcase(left(trim(MyDate(2)),3)) = "Jul" then Mnth = 07 if Lcase(left(trim(MyDate(2)),3)) = "Aug" then Mnth = 08 if Lcase(left(trim(MyDate(2)),3)) = "Sep" then Mnth = 09 if Lcase(left(trim(MyDate(2)),3)) = "Oct" then Mnth = 10 if Lcase(left(trim(MyDate(2)),3)) = "Nov" then Mnth = 11 if Lcase(left(trim(MyDate(2)),3)) = "Dec" then Mnth = 12 response.write MyDate(3) & "-" & Mnth & "-" & MyDate(1) %>
Why?





Where is the date being retrieved from? Perhaps the DatePart() function might be of some use?




Because you changed the format.
if Lcase(left(trim(MyDate(2)),3)) = "Jan" then Mnth =01
You need to leave the months name in lower case "jan" "feb" etc., and put quotes around the month number for the comparison and output to work correctly.
if Lcase(left(trim(MyDate(2)),3)) = "jan" then Mnth = "01"
Bookmarks