How to display 'datetime' as mm/dd/yyyy?

  • How do I display a 'datetime' field in a view as mm/dd/yyyy?

    I'm trying to create a view with the dates in a more user-familiar format. The table I'm selecting from has a column DeedDate that is defined as a 'datetime' type. When I select that column, the field displays like 2008-01-10 09:55:00.000.

    I tried this, but the display didn't change:

    CONVERT (datetime,DeedDate,101)

    Found this by google search, but it didn't change my display:

    CONVERT (datetime,CONVERT(char(10),DeedDate,101))

    Can someone please point me in the right direction? Thanks!

    (I hope it's not too obvious that I'm pretty new at this stuff!)

  • select convert(varchar,getdate(),101)

  • Hello,

    You can use this format. Run this statement in Query Analyzer

    select convert(varchar(12), getdate(), 101)

    Hope this helps.

    Thanks


    Lucky

  • WOW! What a great forum!! Answers that work in practically no time at all!

    THANKS!!

  • Hi 🙂

    Here is what you are looking for:

    SELECT CONVERT (VARCHAR(13),@Vdt,103)

    Please remember that it 99% of the time a better option to format dates on the Client side with the application than it is to with SQL.

    Sql is a database langauge for reading writing etc.

    Enjoy your day

    Chris

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 5 posts - 1 through 4 (of 4 total)

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