Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Date time problem Expand / Collapse
Posted Monday, July 22, 2013 5:46 PM


Group: General Forum Members
Last Login: Monday, March 3, 2014 4:58 PM
Points: 130, Visits: 214
Hi Professionals

I have a column within my database table called todays_date this is

Datetime and in the format
2013-07-23 08:55:59:353

is the a way to update or alter the table so it is in the format
23/07/2013 only

thanks in advance
Post #1476315
Posted Monday, July 22, 2013 7:13 PM



Group: General Forum Members
Last Login: Yesterday @ 1:31 PM
Points: 5,676, Visits: 8,203
datetime is a datatype for storing a date value that includes the time. What you are asking for is the date ONLY (no time), and in a specific format. The first of those can be accomplished with the DATE datatype, and much more efficiently than datetime because date is 3 bytes and datetime is 8 bytes per.

For the second thing, you get a date out of the table in a format based on things such as SET LANGUAGE and SET DATEFORMAT, which can be found in Books Online. See also the CONVERT function in BOL.

I do note though that making a date pretty on OUTPUT is almost always best done OUTSIDE the database, in the presentation layer (whatever that is for you).


Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru at GMail
Post #1476321
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse