Error in SQL

  • Can some one please tell me from this SQL

    select right(convert(varchar,(DATEADD(dd,-(DATEPART(dw, getdate())),getdate())) , 111 ),5)

    Actually this SQL giving: 02/20

    But i wanted to get 2/20

    Thanks

  • What value are you trying to get?

    Depending on the value of the DATEFIRST you'll get different results...

    There might be a more efficient way to do it.

    Regarding the leading zero: What will you display for October, 1st? 10/01, 10/1, or 0/1?



    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]

  • How does this work for you:

    select replace(str(month(getdate()))+'/'+str(day(getdate())),' ','')

    _________________________________
    seth delconte
    http://sqlkeys.com

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

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