Download file and Save As Prior Month and Current Year

How can I download files and save as to include the prior month and current year in them. I have 4 different reports downloaded that need to be saved with the same prior month and current year. For example I need them all to be save like “text_0520.xlsx”. I want to be able to do this for the other months as well and not just May of 2020. Thank you.

That string can be built upon a DateTime object like this:
This month string = Date.Today.ToString(“MMyy”)
Last month string = DateAdd(DateInterval.Month, -1, Date.Today).ToString(“MMyy”)
2 months ago string = DateAdd(DateInterval.Month, -2, Date.Today).ToString(“MMyy”)
and so on…

It’s quite easy,

String strPreviousMnth= Now.addmonths(-1).tostring(“MMyy”)

Above statement would yield 052020.
Please let us know if you need any help.

It worked thank you!

1 Like

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