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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Format a date

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2012-04-19 : 12:32:50
I have a Char field with dates like '20100924' How do I convert it to 09/24/2010

Dave
Helixpoint Web Development
http://www.helixpoint.com

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2012-04-19 : 12:36:16
I got it
CONVERT(varchar, CAST(Last_Transaction_Date AS datetime), 101) AS Expr1


Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-04-19 : 12:37:03
select convert(varchar(20),convert(datetime ,'20100924'),101)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-19 : 14:28:54
why do you again need to convert it back to varchar?

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

Go to Top of Page
   

- Advertisement -