SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Date time problem


Date time problem

Author
Message
Oracle765
Oracle765
SSC-Addicted
SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)

Group: General Forum Members
Points: 458 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
TheSQLGuru
TheSQLGuru
SSC-Dedicated
SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)

Group: General Forum Members
Points: 32683 Visits: 8677
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 on googles mail service
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search