Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 changing the date format
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

glendcruz
Yak Posting Veteran

Australia
60 Posts

Posted - 12/19/2010 :  18:44:51  Show Profile  Reply with Quote
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

China
5 Posts

Posted - 12/20/2010 :  02:55:22  Show Profile  Reply with Quote
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

India
22864 Posts

Posted - 12/20/2010 :  08:50:14  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000