niubbone 0 Posted May 2, 2010 (edited) I need to make a function that adds up a day whenever it's called to a date I setted in a variable. As you see, in this for loop, the date is always the same. How to solve it? And how to make the date format DD/MM/YYYY? #include <Date.au3> Global $date="2010/12/20" Global $NewDate for $i=1 to 5 $sNewDate = _DateAdd('d',1,$date) $data=$NewDate MsgBox( 4096, "", "Today + 1 days:" & $sNewDate ) next Edited May 2, 2010 by niubbone Share this post Link to post Share on other sites
DW1 102 Posted May 2, 2010 Not entirely sure I know what you are asking here, but I will give it a go. If you are asking why the date displayed in the message box is not changing, well, because you are adding 1 day to $date in the For loop, and $date is not changing since you first declared it. Maybe make $NewDate = $date, and keep changing $NewDate in the loop. To change the format... well, many ways to do this one. Looks like you are fairly new to this, so for my example we will just use StringRight, StringLeft, and StringMid for our format change. This is what I came up with... Does that address your concerns? #include <Date.au3> Global $date = "2010/12/20" Global $NewDate = $date For $i = 1 To 5 $NewDate = _DateAdd('d', 1, $NewDate) MsgBox(4096, "", "Today + 1 days:" & _Format($NewDate)) Next Func _Format($FDate) Return StringRight($FDate,2) & '/' & StringMid($FDate,6,2) & '/' & StringLeft($FDate,4) EndFunc AutoIt3 Online Help Share this post Link to post Share on other sites
niubbone 0 Posted May 2, 2010 Well this was the purpose: http://www.autoitscript.com/forum/index.php?showtopic=113835 Btw I'm too tired to read the code and understand it now, i'll give a look tomorrow. Many thanks for the help, works good! Share this post Link to post Share on other sites