# Dynamic date time for schedule task

**URL:** https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312
**Category:** Discussion
**Created:** [June 25, 2008, 9:30am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312 "2008-06-25T09:30:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 25, 2008, 9:30am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/1 "2008-06-25T09:30:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [June 30, 2008, 3:35am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/2 "2008-06-30T03:35:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 30, 2008, 8:54am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/3 "2008-06-30T08:54:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [July 1, 2008, 2:07am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/4 "2008-07-01T02:07:33Z")

</div>

yes, in the BeforeAction script.

---

<div class="post-metadata">

### Author: ![mrrimmer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mrrimmer](https://www.finalbuilder.com/forums/u/mrrimmer)
#### Post date: [August 7, 2014, 2:08am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/5 "2014-08-07T02:08:39Z")

</div>

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 =&nbsp; datevalue(nextrundate)  
action.AbsoluteStartTime = nextrundate  
action.UseStartDate = true  
  
The log:  
  
Set next time job should run  
&nbsp;&nbsp;&nbsp; Status: Completed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date: 07/08/2014  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Time: 13:01:36:849  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End: 13:01:36:866  
&nbsp; 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  
&nbsp;&nbsp;&nbsp; Status: Completed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date: 07/08/2014  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Time: 13:01:36:866  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End: 13:01:38:089  
&nbsp; 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.

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [August 12, 2014, 1:36am UTC](https://www.finalbuilder.com/forums/t/dynamic-date-time-for-schedule-task/4312/6 "2014-08-12T01:36:19Z")

</div>

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!
