StephenT Posted April 1, 2009 Share Posted April 1, 2009 Hello there, I'm a real novice in the scripting language. Does somebody know how to calculate with the date? I'm daily creating reports from Monday thru Friday. The contents of the reports is from the day before and on Monday it will be from last Friday. Now I'm running into a problem. When the 1st of the month falls on a week day, the last day of the previous month will be 00 instead for example 31. Could anyone help me out? The script I'm using is: #include <Date.au3> $curdate = _NowCalcDate() ;remove "/" from the date format $curdate = StringReplace ( $curdate, "/", "" ) ;declaration $prevdate = $curdate - 1 MsgBox (0,"test", $prevdate&" "&$curdate) Many thanks! Link to comment Share on other sites More sharing options...
Zedna Posted April 1, 2009 Share Posted April 1, 2009 (edited) #include <Date.au3> $sNewDate = _DateAdd( 'd', -1, _NowCalcDate()) MsgBox( 4096, "", "Today - 1 day:" & $sNewDate ) Edited April 1, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
rudi Posted April 1, 2009 Share Posted April 1, 2009 (edited) Hi. As today is April, 1st, it's a perfect day to directly check #include <date.au3> ConsoleWrite(_NowCalcDate() & @CRLF) ConsoleWrite(_DateAdd("d", -1 , _NowCalcDate()) & @CRLF) Regards, Rudi. Edited April 1, 2009 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
StephenT Posted April 2, 2009 Author Share Posted April 2, 2009 #include <Date.au3> $sNewDate = _DateAdd( 'd', -1, _NowCalcDate()) MsgBox( 4096, "", "Today - 1 day:" & $sNewDate ) Hi Zedna, It works, thanks! I cracked my brains but no results. Again, thanks for taking time to check my issue! Link to comment Share on other sites More sharing options...
StephenT Posted April 2, 2009 Author Share Posted April 2, 2009 Hi. As today is April, 1st, it's a perfect day to directly check #include <date.au3> ConsoleWrite(_NowCalcDate() & @CRLF) ConsoleWrite(_DateAdd("d", -1 , _NowCalcDate()) & @CRLF) Regards, Rudi. Rudi, Thanks for having a look at my problem! It works for me. 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