Results 1 to 2 of 2

Thread: datepart month

  1. #1
    Join Date
    Sep 2003
    Location
    Danville CA
    Posts
    6

    datepart month

    I am converting a datetime value to char using datepart(mm,datefield).

    I would like the month to be 2 digits - 01,02,03...11,12 - but it only returns 1,2,3...11,12. What can I add to do this? thanks in advance.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    select select right('00'+rtrim(ltrim(cast(datepart(mm,datefield) as char(2)))),2)from yourtable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •