Dynamic date time for schedule task

Hi,

My latest project with Automise, I am trying to schedule tasks, based on dates and times comming from a database. Grabbing this is ne sweat, but scheduling the task on a date and time stored in variables has turned out to be a challenge. Is this possible at all?

Hans-Henrik

Hi Hans-Henrik,

If you use the Add Scheduled Task action, you can change the StartDate from script:
Action.StartDate = TheNewDate

If you’re using the Schedule Add action, then it’s a lot harder as you have to set hours, minutes, days separately, eg.
Action.PropertyStore.absDay = TheDay

.t8

So, I would do this through the BeforeAction script, right?

yes, in the BeforeAction script.

Apologies for resurrecting an old thread, but I’ve got a strange error whilst trying to do this.
Using a bit of SQL to get a datetime value , then set off a new scheduled task with that value.
The date is always 15/03/2029.

NextRunDate is a date variableuse dto capture the output of the ADO Execute SQL action

The code in Add Scheduled Task:
Action.StartDate =  datevalue(nextrundate)
action.AbsoluteStartTime = nextrundate
action.UseStartDate = true

The log:

Set next time job should run
    Status: Completed
      Date: 07/08/2014
      Time: 13:01:36:849
       End: 13:01:36:866
  Duration: 00:00:00:017

Action Messages:
07/08/2014 13:03:37

Output Monitor : 1 matches for “*” written to variable NextRunDate

Add Scheduled Task
    Status: Completed
      Date: 07/08/2014
      Time: 13:01:36:866
       End: 13:01:38:089
  Duration: 00:00:01:223

Action Messages:
Command line : schtasks /Create /TN “Automise4 - Mirror FTP Sites” /RU cowatch\Administrator /RP ****** /SC ONCE /TR ““C:\Program Files (x86)\Automise 4\ATCMD.exe” /o /p"D:\Products\Automise\FTP Sync\FTP Site Mirror.atz4"” /ST 13:03:37 /SD 15/03/2129
Executing external process: C:\Windows\system32\schtasks.exe
Starting Directory: C:\Windows\system32<br>Parameters: /Create /TN “Automise4 - Mirror FTP Sites” /RU cowatch\Administrator /RP **** /SC ONCE /TR ““C:\Program Files (x86)\Automise 4\ATCMD.exe” /o /p"D:\Products\Automise\FTP Sync\FTP Site Mirror.atz4"” /ST 13:03:37 /SD 15/03/2129
Output from C:\Windows\system32\schtasks.exe
SUCCESS: The scheduled task “Automise4 - Mirror FTP Sites” has successfully been created.

Hi Mr Rimmer,

Its hard to see what the value of the date would be from the output monitor. The output monitor will take the text from the match and place it into the variable. From memory the conversion from text to datetime is very particular about the date format.

Please send us a cut down project which shows the issue to support. From there I will be able to see more clearly what is occurring and either fix the issue or give you a solution which works.

Thanks!