Results 1 to 3 of 3

Thread: Need 2 digit month returned; not 1 digit

  1. #1
    BTphila Guest

    Need 2 digit month returned; not 1 digit

    How can I return a 2 digit month into a variable for the months Jan thru September

    SELECT DATEPART(mm, GETDATE()) ---> returns 9 for September.. I need 09 returned in order to properly build my target file name...

    Thx,
    BT


  2. #2
    Rajesh Chopra Guest

    Need 2 digit month returned; not 1 digit (reply)

    use this code

    select left(CONVERT ( char(20) , getdate() , 101 ),2)


    ------------
    BTphila at 9/5/01 10:13:28 AM

    How can I return a 2 digit month into a variable for the months Jan thru September

    SELECT DATEPART(mm, GETDATE()) ---> returns 9 for September.. I need 09 returned in order to properly build my target file name...

    Thx,
    BT


  3. #3
    Bill Guest

    Need 2 digit month returned; not 1 digit (reply)


    select right(CONVERT ( varchar(20) , getdate() , 101 ),2)


    ------------
    Rajesh Chopra at 9/5/01 1:46:54 PM

    use this code

    select left(CONVERT ( char(20) , getdate() , 101 ),2)


    ------------
    BTphila at 9/5/01 10:13:28 AM

    How can I return a 2 digit month into a variable for the months Jan thru September

    SELECT DATEPART(mm, GETDATE()) ---> returns 9 for September.. I need 09 returned in order to properly build my target file name...

    Thx,
    BT


Posting Permissions

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