DateTime variable value changing when automation runs for multiple days


I am currently working on an automation where the first thing I do is create a day folder: DayFolder = “filepath/” + in_Day.ToString(“yyyy-MM-dd”), where in_Day = Today.Date.AddDays(0). At the end of the automation, I will be writing the result of the automation to an Excel file in this DayFolder.

My question is, if I run the automation today (2019-12-27) and the automation finishes tomorrow (2019-12-28), will the in_Day variable still store the date when the automation was run (2019-12-27)? Because if this is not the case, my automation will not write the results back to Excel…

The value of DateTime.Today or DateTime.Now will hold the date or time at the specific point that it is called.

That been said, all you have to do is create this name in the begging of the automation execution. So even if it finishes in the next day, the value will already be stored and won’t change.

Oh okay. I create this variable in the beginning of the automation but I was worried that it would change if the automation continues on to the next day. So if I create this variable at the start of the automation, the date it will store will be the date on which the variable was created, correct?


1 Like

Thank you so much!

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