Date time problem

  • 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

  • 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

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply