You don't need to go through all that. The nice thing about the way CDate stores it is you only need one comparison. E.g. a date is stored as one single floating point value YYYYMMDD.HHIISS. Which in turn means comparing equality takes account of all the portions of the date/time in one go:
Code:
(defun RunCode () (princ "Run My Code"))
(if (> newDate oldDate)
(RunCode)
)
Would be equivalent to something like this:
Code:
(if (> (fix (/ newDate 10000)) (fix (/ oldDate 10000))) ;Check Year
(RunCode)
(if (> (rem (/ newDate 100) 100) (rem (/ oldDate 100) 100)) ;Check Month
(RunCode)
(if (> (rem newDate 100) (rem oldDate 100)) ;Check Day
(RunCode)
(if (> (rem (* newDate 100) 100) (rem (* oldDate 100) 100)) ;Check Hour
(RunCode)
(if (> (rem (* newDate 10000) 100) (rem (* oldDate 10000) 100)) ;Check Minute
(RunCode)
(if (> (rem (* newDate 1000000) 100) (rem (* oldDate 1000000) 100)) ;Check Second
(RunCode)))))))