Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Date time problem Expand / Collapse
Author
Message
Posted Monday, July 22, 2013 5:46 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

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


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:44 PM
Points: 4,359, Visits: 6,197
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).


Best,

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