Alex037 Posted April 30, 2022 Share Posted April 30, 2022 Hello everyone, I was looking for an addition to a current script that runs daily. Due to the constrains on servers (tasks that run between 2AM and 7AM), I now have to modify the current script to run differently. I got it to work while it is on the same day (starts and finishes at the same day), but now I have to span it across days. For example, it has to be started somewhere between 14.00 and 18.00 (it is operators decision) and it will continue to run until 2AM next day. Then pauses, and continues after 7AM. According to the past work history, it will finish around 9-10AM, so there is enough time to verify data and prepare for the next run. Thanks in advance. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2022 Developers Share Posted April 30, 2022 Great, so what exactly is the question and what have you tried? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Solution Alex037 Posted April 30, 2022 Author Solution Share Posted April 30, 2022 (edited) I have never used date function until now. Playing with examples to figure it out. Idea is to record current date at the beginning of the script, set new variable that will add 1 day. At the end of every script iteration it should check if $sNewDate is equal to $sDate (so it is past midnight, right), and then to check for current time. If the current time is greater than 2AM, pause until 7AM. So far I am getting zero as result. #include <Date.au3> #include <MsgBoxConstants.au3> Local $sDate = _NowDate() Local $sNewDate = _DateAdd('d', 6, _NowCalcDate()) Local $iDateCalc = _DateDiff('d', $sDate, $sNewDate) MsgBox($MB_SYSTEMMODAL, "", "" & $iDateCalc) Ok, I got it somehow to show difference. Error was in _DateDiff #include <Date.au3> #include <MsgBoxConstants.au3> Local $sDate = _NowDate() Local $sNewDate = _DateAdd('d', 2, _NowCalcDate()) Local $iDateCalc = _DateDiff('d', $sNewDate, _NowCalc()) MsgBox($MB_SYSTEMMODAL, "", "" & $iDateCalc) This now shows -2 as a result. Edited April 30, 2022 by Alex037 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now