Date change if the run job between two days

Hi everyone,

I develop a script which is scheduled a 10:00 PM, the job is very long and finish the day after at 5:00 AM.

This script use daytime.now and i wonder if the date used during the job is the date at the start of the job or if this date change after midnight.

I want to keep the date of the day of start, is there a method to keep this date ?

Thank you for your help,

Guillaume Cabanes

@guillaume.cabanes2

Create a datetime variable and at the start of the process ave the Now() value to it…and use the same across

If you need as string then save as string at the start and that should do your job

Hope this helps

Cheers

Hi @guillaume.cabanes2 ,

If DateTime.Now is being used in multiple places, say at the beginning of the process and at the end of the process. Then this will contain two different values, as it is invoking the DateTime method and retrieving the date at that specific time.

In order to retain the value throughout, you should use a variable either a DateTime type or a String type as already mentioned by @Anil_G to make the same value available at all times.

Thank you for your answer

yes i did it but it was more in case i have to start again a failed job. Do you think it will work if i send Datetime.now as an argument with Orchestrator?

@guillaume.cabanes2

Then save the value as asset in the orchestrator at the strt of process…and make it empty at the end of process…so at start you can check if the value is empty or na then its fresh run else its rerun and can use the same value present in the orchestrator asset

So basically include a get asset at start of process if value is NA set the value to now.Tostring and the value is stored…

And make sure to set the asset bavk to na for following day…

If at all the bot fails in between thwn the value still remains in asset and as the value is not na the value is not set and you can use the date in rerun

Hope this helps

Cheers

1 Like

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