How to Rename excel file with date

Hello Community,

I have scenario where in i need to copy template file and move to output folder,
though i am able to copy and rename filename followed by current month and year.

strTempName=strTempName.Replace(“{0}”,Now.ToString(“MMyyyy”))

output is :- VarianceAnalysis_012021.xlsx

but expected output is :- VarianceAnalysis_0121.xlsx

Need Suggestions. @NIVED_NAMBIAR

1 Like

Hi put the filename as below

“VarianceAnalysis_”+Now.ToString(“MMyy”)+“.xlsx”

1 Like

Thanks For the reply i tried ,but i am getting Same output no change

HI @ShivuDundi,

also you can try this, “VarianceAnalysis_012021.xlsx”.Replace(Now.ToString(“yyyy”),Now.ToString(“yy”))

image

Just edited my answer

Please check

1 Like

I got it …Thank You

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.