Jump to content

Recommended Posts

Posted

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)

 

Posted

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

Posted (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 by Lee Mac
  • Like 2
  • Thanks 1
Posted

@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! 🙂

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...