# Database Discussions > MS SQL Server 7/MS SQL Server 2000 >  Need 2 digit month returned; not 1 digit

## BTphila

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

----------


## Rajesh Chopra

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

----------


## Bill

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

----------

