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
 format in 2010

Author  Topic 

seeker62
Starting Member

40 Posts

Posted - 2013-01-18 : 12:55:20
This
FORMAT(CONVERT(VARCHAR(8),CAST(@end_value AS DATE),112), 'MM/DD/YYYY')

gives me an error saying that FORMAT is not recognized so how do I format a date string into mm/dd/yyyy

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-01-18 : 13:05:20
using the 101 option and CONVERT you can get the format you require. Read more in books online

SELECT CONVERT(nvarchar(10), GETDATE(), 101) AS Convert_to_101 ;

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-18 : 13:12:13
FORMAT() function is only available from 2012 onwards

Ideally you should be trying to do formatting at front end if possible. Converting dates to varchar just for formatting is an overkill

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

Go to Top of Page

seeker62
Starting Member

40 Posts

Posted - 2013-01-18 : 15:54:53
Thanks your input created a fix.
Go to Top of Page
   

- Advertisement -