Add leading zero to single digit months

Database
Enthusiast

Add leading zero to single digit months

,case when EXTRACT (month FROM CURRENT_DATE)  > 8 then 
 EXTRACT (month FROM CURRENT_DATE)  - 8
 else
 EXTRACT (year FROM CURRENT_DATE)  +4
 end as MyDay

This is the code I have to extract the ccurrent month and convert it to an accounting period.  The only thing I would like to do now is to add a leading 0 to the single digit months.  So 1 becomes 01, 2 becomes 02, etc.  Thanks for the help

1 REPLY
Enthusiast

Re: Add leading zero to single digit months

trim(extract(month from date) (format '99'))

try this