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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Changing Date column to different format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

Posted - 01/17/2013 :  08:31:22  Show Profile  Reply with Quote
Hello there

I have a datetime column that reads 1997-11-25 16:29:00.000

is there a way i can update the whole column to permanently read

eg todays date 17-01-2012 12:22:00.000


Regards


Rob

James K
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 01/17/2013 :  08:47:08  Show Profile  Reply with Quote
Assuming that data type of the column is DATETIME, DATETIME2 or one of the other datetime types, the data is stored in SQL Server without regard to the formatting. So what you are observing when you select is simply an artifact of the default format applied (which depends on your locale setting and language setting).

If you want to get the results in the format you have indicated (or any other format) you can format it approriately. So to get the format you specified, you would do this:
CONVERT(VARCHAR(32), YourDateColumn, 120)
120 is a format style. The format styles available are listed on this MSDN page http://msdn.microsoft.com/en-us/library/ms187928.aspx

Usually it is better to do this type of formatting at the point where the data is consumed - for example in a front-end application or in Reporting Services.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000