MrCheese Posted December 30, 2015 Posted December 30, 2015 (edited) Hi there,I'm wanting to put in a line that determines whether the current date is passed the 'expired' date which is included in the code. I have the idea? But am not overly familiar in determining all the functions in the date.au3 extension.#include <Date.au3> Local $expdate = _SetDate(01, 02, 2016) Local $datediff = _DateDiff('D', $expdate, _NowCalc()) If $datediff = 0 Then MsgBox(0, "Expired", "Sorry, this program has expired, contact me for an extension.", 15) Exit EndIf And tried this:#include <Date.au3> Local $currdate = _Date_Time_GetSystemTime() Local $expdate = _SetDate(01, 02, 2015) If $currdate > $expdate Then MsgBox(0, "Expired", "Sorry, this program has expired, contact me for an extension.", 15) Exit EndIf Any assistance would be very appreciated. Thanks Edited December 30, 2015 by MrCheese
jguinch Posted December 30, 2015 Posted December 30, 2015 (edited) _SetDate changes the system date.You can put the date as string directly in _DateDiff :#include <Date.au3> $endDate = "2016/02/01" Local $datediff = _DateDiff('D', $endDate, _NowCalc() ) If $datediff > 0 Then MsgBox(0, "Expired", "Sorry, this program has expired, contact ....@gmail.com for an extension.", 15) Exit EndIfNote that it is possible do use this :$endDate = "20160201" If $endDate < (@YEAR & @MON & @MDAY) Then MsgBox(0, "Expired", "Sorry, this program has expired, contact .....@gmail.com for an extension.", 15) Exit EndIfEdit : sorry, my code was wrong... Edited December 30, 2015 by Jos removed email Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
orbs Posted December 30, 2015 Posted December 30, 2015 it is common that _DateDiff() sees the earlier date first, so better use:Local $datediff = _DateDiff('D', $expdate, _NowCalc()) ; earlier date firstthe above is not mandatory, but it makes more sense, because the diff can be negative. so most important - the condition must be:If $datediff <= 0 Thenbecause if it's only = 0 (equals to zero) rather than <= 0 (equals or smaller than zero) then when your users run your program few days after the expiration date, it "becomes" functional again...this is addressed in the 2nd snippet of the post by @@jguinch (but not the first). and finally, the obvious word of advice - this type of obsolescence method is not very difficult to overcome. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
MrCheese Posted December 30, 2015 Author Posted December 30, 2015 (edited) Hi guys,Thank you heaps for your input. I went with this code: $endDate = "20160201" If $endDate < (@YEAR & @MON & @MDAY) Then MsgBox(0, "Expired", "Sorry, this program has expired, contact ....@gmail.com for an extension.", 15) Exit EndIfAny concerns with that? Edited December 30, 2015 by Jos Removed Email
Developers Jos Posted December 30, 2015 Developers Posted December 30, 2015 Code should work, but my only concern would be that you just posted your Email address in your last post which could trigger lots of spam. Jos 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.
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