How to create folder using prior business date

Hey there- Using the below code currently for creating a new folder daily. The code is working but creating the folder with the current business date. How can I work it so it creates the prior business day’s date?

“C:\Users…”+Datetime.today.tostring(“yyyy-MM-dd”)

Thanks!

1 Like

@dylan.kelly

Please use like this

Path.Combine("C:\Users…",Datetime.today.AddDays(-1).tostring("yyyy-MM-dd"))

Path.Combine will add strings in proper location format

And addDays(-1) will remove 1 day

Cheers

1 Like

will the bot run on Monday and has to create Friday from the previous week folder?
In such case we could do:

Now.AddDays({-2,-3,-1,-1,-1,-1,-1}(Now.DayOfWeek)).toString("yyyy-MM-dd")

That worked! Thank you!!

1 Like

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