TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: @_Bilal on January 19, 2019, 07:35:15 AM
-
Hi Guys,
Is there an AutoLISP routine to deduct two dates and get the results in days
for example: last date is "19750225" year 1975 month 02 day 25 and the current date is (rtos (getvar "cdate") 2 0)
The question is how to get the exact days between this 2 dates in autolisp.
Thanks
-
Convert the dates to Julian then subtract, e.g.:
(- (fix (dtoj d2
)) (fix (dtoj d1
))) )
_$
(daydiff
20190117 (getvar 'cdate
))2
_$
(daydiff
20181219 (getvar 'cdate
))31
(dtoj is part of Julian.lsp included with Express Tools)
Note that the DATE system variable returns a Julian date already, so if you simply want the difference from the current date, the code may be:
_$ (daydiffnow 20190117)
2
-
Thank you Lee Mac.