January 14, 2010 at 3:54 pm
Hi everyone,
I would like to convert varchar data to datetime
sno varchar datatype to datetime datatype
1. 20090420 (format of yyyymmdd) to 2009-20-04 (format of yyyy-dd-mm)
2. 15/02/09 (format of dd/mm/yy) to 2009-02-15 (format of yyyy-mm-dd)
please let me know.
thanks in advance....
Thanks,
sai
January 14, 2010 at 4:13 pm
This site should be useful for you.
http://www.sqlusa.com/bestpractices/datetimeconversion/
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 14, 2010 at 4:30 pm
Hi Jason,
First of all I appreciate for suggesting me the link. I would like to convert a varchar data which is in mmddyyyy to datetime format
Thanks,
sai
January 14, 2010 at 4:48 pm
Hi Jason,
I got the answer for that
select convert(datetime,substring('10232016',1,2)+'/'+substring('10232016',3,2)+'/'+substring('10232016',5,4),101)
Thanks for your help.
sai
January 14, 2010 at 4:51 pm
saidwarak01 (1/14/2010)
Hi Jason,I got the answer for that
select convert(datetime,substring('10232016',1,2)+'/'+substring('10232016',3,2)+'/'+substring('10232016',5,4),101)
Thanks for your help.
sai
You're welcome.
When doing your actual conversions, make sure you replace that static date in the ' '
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply