Save file with different name for each day

Hi,

I´ve done a daily report in Excel with Studio X. I wish that I could save the file of each day as “20210201.xls”, 20210202" and so on. One file with unique name for each day.

How do I solve this?

BR,
Magnus, Sweden

Hello, @magnus2.andersson

if you want to save the file with the current date, you can use this to get that:

DateTime.Now.ToString(“yyyyMMdd”)

Also you might need some aditional steps, like giving the path where you want to save the file, followed by that piece of code to give the current date.

Hope this is useful.
Happy Automation :robot:

Hello,
Thank´s for your answer.

The file is saved with todays date and I am satisfied so long.
But I get this error message and don´t know how to handle it:

Illegal characters in path.

You can find the activity following this path:

Main > Use Excel File > Save Excel File As.

Excel file path: 20210205.xlsx

My path for “Save as” is= H:\UiPath\spara fil"DateTime.Now.ToString(“yyyyMMdd”).xlsx"

Best Regards,
Magnus

Great to know that the file name works.
I’ve never faced that “Illegal characters in path” problem, tell me one thing, if you add a backslash before the date, does it still show that error? What I’m saying is having your “Save as” like this:

“H:\UiPath\spara fil\” + “DateTime.Now.ToString(‘yyyyMMdd’).xlsx”

Also if you can send a print screen of your code with the error, it would be helpful.

Tried to change “”, “/” and ’ instead of " and so on, but i still got the error message.

Best Regards,
Magnus

@magnus2.andersson - There is an easy way to do it in Studiox without a formula…

After Adding the initial path , click on the + sign and choose text which open the text editor. Inside click the plus sign again, this time choose notebook==> Date==> and YYYYMMDD…as shown below…that’s it…

My Output:
image

Thank´s a lot!

That was helpul, case closed :slight_smile:

Best Regards,
Magnus

@magnus2.andersson … Glad it worked…Please mark my post as solution , that will close this thread.

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