Aftertouch Posted February 6 Posted February 6 Hi all, I am using a LISP to use some automation within the company. For this case... im using it to convert a Excel file to an VCF-file, to import in phones. But now..... I can save the current date with: (setenv "TELNUMBERS" (rtos (getvar "CDATE") 2 0)) I use this to store the date of the last time the code is executed. But... i want a detection that the last update has been more that 7 days. How can i calculate the diference between to dates? A simpel substraction wont work.... since its date-formated.. So... current date minus the stored date, should be 7 or more... something like (if ( > (- (rtos (getvar "CDATE") 2 0) (getenv "TELNUMBERS")) 7) Quote
Steven P Posted February 6 Posted February 6 RTOS converts a number to a string and of course you cannot do mathematical operation onto a string. Maybe convert TELNUMBERS back to a number with ATOF (or ATOI if you want an integer). CDATE is in seconds I think so you'll want to divide the result by (60 x 60 x 24) 86400 to get days Quote
Lee Mac Posted February 6 Posted February 6 (edited) Use DATE instead of CDATE: https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-CBB24068-1654-4753-BE2E-1D0CE9700411 DATE stores the date value as a Julian date, which simply counts the number of days which have elapsed from a given epoch - as such, you can easily subtract two integer Julian date values to calculate the number of elapsed days between two dates, e.g.: (< 7 (- (getvar 'date) (atoi (getenv "TELNUMBERS")))) (assuming you have changed TELNUMBERS to store the DATE value instead of CDATE) Edited February 6 by Lee Mac 2 1 Quote
Aftertouch Posted February 7 Author Posted February 7 @Lee Mac thanks, seems like that did the trick! Need to wait a few days to actualy test the code, but the detection seems to do what i want it to do! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.