MrCheese Posted November 1, 2016 Posted November 1, 2016 Hi guys, I have some code; which doesn't quite work. $dateStop = "11302015" $tDate = _Date_Time_GetSystemTime() $currentdatestring = _Date_Time_SystemTimeToDateStr($tDate) If $currentdatestring >= $dateStop Then MsgBox(0, "Expired", "Script has expired.") Exit EndIf Basically, I want to essentially put an expiry date on the script. Where in the example above, it is 30th November 2015. Sometimes it works, sometimes it doesn't. I may have the string wrong, I may have the code all wrong. I thought about using the macro @mon @year etc but it gets quite conditional. i.e. if its 2015, but October, or if its 2015 and Dec, or if its March 2016 etc. But simplicity is great. Any help would be awesome.
mikell Posted November 1, 2016 Posted November 1, 2016 (edited) May I suggest the YYYY/MM/DD date format to make things easier Then you could use _DateDiff() , or this #include <Date.au3> $dateStop = "2015/11/30" $dateStopstring = StringReplace($dateStop, "/", "") ; $currentdatestring = StringReplace(_NowCalcDate(), "/", "") $currentdatestring = @YEAR & @MON & @MDAY If $currentdatestring >= $dateStopstring Then MsgBox(0, "Expired", $currentdatestring & @crlf & $dateStopstring) Exit EndIf Edited November 1, 2016 by mikell
MrCheese Posted November 2, 2016 Author Posted November 2, 2016 (edited) Excellent. I wasn't sure how the date strings would work in that >= context. Thanks for your help! Edited November 2, 2016 by MrCheese
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