TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AMAM on April 21, 2020, 06:08:18 AM

Title: add / subtract dates
Post by: AMAM on April 21, 2020, 06:08:18 AM
Is there is any way of adding for example 30 minutes to the result of "(rtos (getvar 'cdate) 2 6)" also the reverse,
keep in mind in special occasions that might result in jumping to the next day, month or year.
Title: Re: add / subtract dates
Post by: Lee Mac on April 21, 2020, 08:33:30 AM
I would suggest using the value returned by DATE rather than CDATE.

DATE stores the current date & time as a Julian date value, with the value following the decimal point representing the fraction of a day. Hence, to add 30 minutes you simply need to divide 30 by the number of minutes in a day (1440) and add this to the value returned by the DATE system variable.

The result can then be represented in a human readable format using the DIESEL edtime function, evaluated from a menu command expression, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (menucmd "m=$(edtime,$(+,$(getvar,date),$(/,30.0,1440.0)),yyyy-mo-dd hh:mm:ss)")
Title: Re: add / subtract dates
Post by: AMAM on April 21, 2020, 11:04:49 AM
THANK YOU ALOT SIR,
For easy solution and the explanation I'm really grateful.