So I am trying to add a zero in front of the single digit months. for example my code below gets me *_22025_CCC.xlsx, I would like it the month number to always be two digits. I should look the this *_022025_CCC.xlsx
"*_" + (DT_WSTR, 2) Month(DATEADD( "M", -1, GETDATE())) + (DT_WSTR, 4) Year(DATEADD( "M", -1, GETDATE())) + "_CCC.xlsx"
I have tried putting another "M" in the month section of the dateadd but that did not work.
can someone please help?
A solution from my comment above that I used in expression builder in SSIS:
"*_" + Right("0" +(DT_WSTR, 2) Month(DATEADD( "M", -1, GETDATE())), 2) + (DT_WSTR, 4) Year(DATEADD( "M", -1, GETDATE())) + "_CCC.xlsx"
I added RIGHT("0" + YourDatePieceForMonth, 2).
This will add a 0 to the start of the string, and if it is single digit it will append the 0 to it. If it is a 2 digit month it will append the 0 to it and make it 012 (for December) but taking the RIGHT 2 only will take it back to 12 for months that have 2 digits.
The same thing works if you need to do this for a day, hour, minute, etc