Date display in SQL Query Manager (and to output to text file via SP)

  • I need to display (and output to txt file) dates returned from a table in the format MM/DD/YYYY.   The field is formatted as "datetime 8" and when queried in query analyzer displays as '1991-05-09 00:00:00.000'.    Any suggestions on this would be greatly appreciated.

     

    Thanks!

      

  • check BO for CONVERT


    Kindest Regards,

    Vasc

  • Thanks.... already looked there. but I don't (cannot!) convert the native data in the source table.. I just need to display and output it in the manner outlined.

  • How does this work for you?

     

    SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS MMDDYYYY

     

    OR

    SELECT CONVERT(VARCHAR(10), DateCol, 101) AS DateCol from dbo.YourTable

  • Ahhh.. so the "convert" does not mean it will convert the native data... .got it...

    Thanks.. works great!!!

  • No, only an update command can do that .  You can transform the data as you wish when you select it .

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

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