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 2005 Forums
 Transact-SQL (2005)
 Date Conversion

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2014-07-14 : 06:55:59
Hi All,
I have a column which contain dates like below. Is there any way if I can change this to MM/DD/YYYY

Please Suggest

Sep 7, 2013
Aug 20, 2013
Aug 21, 2013
Aug 22, 2013
Aug 20, 2013
Aug 21, 2013
Aug 22, 2013
Aug 26, 2013

MichaelJSQL
Constraint Violating Yak Guru

252 Posts

Posted - 2014-07-14 : 07:17:36
I gather the column is a varchar.

SELECT CONVERT(varchar(10),Cast(ColumnName as date),1)
SELECT CONVERT(varchar(10),Cast('Sep 7, 2013' as date),1)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-07-14 : 22:19:53
if you are using varchar to store dates, you should really consider changing the data type to datetime.

As for the formatting MM/DD/YYYY, leave it to your client application to do the job and not in SQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -