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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 hyphens to a date

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2011-08-29 : 09:16:02
what is the syntax to add hyphens to a date in a query for example if the referral date is listed as "20110630" in the results, how can i change that format to "2011-06-30"?

Roger DeFour

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-08-29 : 09:38:07
Formation should be done in the front end application

declare @dt char(8)
set @dt='20110630'
select convert(char(10),cast(@dt as datetime),120)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-29 : 10:29:14
why do want to do this in a query?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -