Date Format

  • How can I convert this date format: 2010-09-08 13:45:00.000 to Wed, Sep 08, 10

  • In Books Online (Help-Index), look up the CONVERT() function. It will give your your date time formatting options there.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • I looked it up online before posting, but I was not able to find the format I was looking for.

  • Example below:

    declare @blah DATETIME

    SET @blah = '2010-09-08 13:45:00.000'

    print LEFT( datename(dw, @blah), 3) + ', '

    + left( datename( month, @blah), 3) + ' '

    + datename( dd, @blah) + ', '

    + right( datename( yy, @blah), 2)

    If you're looking for all the date manipulation functions, check out in BoL:

    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/83e378a2-6e89-4c80-bc4f-644958d9e0a9.htm


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • ejbatu1 (9/8/2010)


    I looked it up online before posting, but I was not able to find the format I was looking for.

    How is this going to be used? Usually formatting is done at the presentation layer. In the past when I absolutely needed to do this, I used an ugly set of CASE statements to Hardcode it from a series of datepart()'s. I am sure there are other ways.

    -- Cory

  • This is for Reporting...

    Thank you Craig that worked.

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

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