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)
 changing the date format

Author  Topic 

glendcruz
Yak Posting Veteran

60 Posts

Posted - 2010-12-19 : 18:44:51
Can any one help me out please.

I have date formats of this type
4th December 2010
15th December 2010

How can I change the format to
2010/12/4
2010/12/15

Any short approaches to it- much appreciated
Thanks

unfiresniper
Starting Member

5 Posts

Posted - 2010-12-20 : 02:55:22
you wanna the result to be string?

convert(nvarchar(50),#datetime field#,111)
or
you can just use cast(year(#datetime field#) as nvarchar(4)) + '/' + cast(month(#datetime field#) as nvarchar(2)) + '/' + cast(day(#datetime field#) as nvarchar(2))
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-20 : 08:50:14
What is the datatype of the column? Always use proper DATETIME datatype and leave formation at front end application

Madhivanan

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

- Advertisement -