need help on convert function dates

  • hi all,

    please help me to get this out put.

    details:

    declare @deadline Datetime = '2014-03-23 15:30:10.000'

    SELECT CONVERT(VARCHAR(30),@deadline, 100) AS DateConvert

    ----With this I am able to produce that like

    ----o/p: Mar 23 2014 3:30PM

    declare @deadline1 Datetime = '2014-03-03 15:30:10.000'

    SELECT CONVERT(VARCHAR(24),@deadline1, 100) AS DateConvert

    --o/p: Mar 3 2014 3:30PM

    --expected O/p: Mar 03 2014 03:30PM

    Please suggest the correct date format to achieve this.

  • A replace can work for you.

    SELECT REPLACE( CONVERT(VARCHAR(24),@deadline, 100), ' ', ' 0')

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • thank you so much for your help.

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

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