How to Cast ''YES '' & datetime field for display purposes

  • Hi,

    Can someone tell me how I can concatenate two fields to display 'Yes dd/mm/yyyy hh:mm:ss'? Where 'Yes' is hardcoded and the dd/mm/yyyy hh:mm:ss is being pulled from an existing date time field.

    Thanks for your help.

     

  • I think I have answered my own question;

    CAST('YES ' + CONVERT(VARCHAR, 'DateTime field', 103) AS VARCHAR(30))

    Thanks

  • DECLARE @Date DATETIME

    SET @date = (SELECT GETDATE())

    SELECT 'Yes ' + CONVERT(VARCHAR(10),@date,101) + ' '  + CONVERT(VARCHAR(10),@date,108)

     

     

    Prasad Bhogadi
    www.inforaise.com

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

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