Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
A table stores the date value as 20111111111111.Kindly let me know how to convert to date format dd/mm/yyyy.Thanks,Sandesh
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2011-11-15 : 10:58:55
you can do something like
SELECT STUFF(STUFF(STUFF(STUFF(STUFF(CAST(datefield AS varchar(30)),5,0,'-'),8,0,'-'),11,0,' '),14,0,':'),17,0,':') FROM table
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2011-11-15 : 11:18:15
Any chance you can store your data in the proper data type instead?
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts
Posted - 2011-11-15 : 11:41:13
Depends on what the format and datatype is but maybe a start isselect convert(datetime,left(fld,8),112)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.