tybtech Posted January 9, 2015 Share Posted January 9, 2015 Hello, I'm trying to use the _dateadd function in a more complicated script, but the issue is the same even in the most simplifed script. For example: #include <Date.au3> #include <MsgBoxConstants.au3> $cycles = 4 $stdt = "2015/01/31" $repeat=1 Do $stdt1 = _DateAdd('m', 1, $stdt) $stdt1f = _DateTimeFormat($stdt1,2) msgbox(0,'',$stdt1) $stdt=$stdt1 $repeat += 1 Until $repeat = $cycles My end goal is to have a variable that cycles forward 1 month every time the script repeats for a specified number of times. With the script I have right now, strangely the first time through, it cycles perfectly to 02/28/2015, but then the days get stuck and I get 03/28/2015 then 04/28/2015 and so forth. Help! Link to comment Share on other sites More sharing options...
Solution Malkey Posted January 9, 2015 Solution Share Posted January 9, 2015 Welcome It appears you were progressively adding one month onto the previous answer. So February 28 plus 1 month equals March 28. #include <Date.au3> #include <MsgBoxConstants.au3> $cycles = 4 $stdt = "2015/01/31" $repeat = 1 Do $stdt1 = _DateAdd('m', $repeat, $stdt) $stdt1f = _DateTimeFormat($stdt1, 2) MsgBox(0, '', $stdt1 & @CRLF & $stdt1f) ;$stdt = $stdt1 $repeat += 1 Until $repeat = $cycles Link to comment Share on other sites More sharing options...
tybtech Posted January 10, 2015 Author Share Posted January 10, 2015 This was massively helpful. You figured out what I needed without me even properly asking what I needed! Thanks! 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