change to 12 hour time format

  • using this: http://www.tek-tips.com/faqs.cfm?fid=4191

    executing this sql on that procedure select dbo.fn_formatdatetime (getdate() ,'h:nnAM/PM');

    always returns the 24 hour time format , I want it to return the 12 hour time format.

    Or you can give me another sql to do that

  • How about using CONVERT?

    SELECT RIGHT(CONVERT(CHAR(19),GETDATE(),100),7)



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • man9500 (5/30/2010)


    using this: http://www.tek-tips.com/faqs.cfm?fid=4191

    executing this sql on that procedure select dbo.fn_formatdatetime (getdate() ,'h:nnAM/PM');

    always returns the 24 hour time format , I want it to return the 12 hour time format.

    Or you can give me another sql to do that

    Unless there just isn't one, this type of formatting should be done only in the GUI. Certainly, you should never save formatted date info in a table.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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