Quote:
Originally Posted by ownedbycats
Is this the only way to check that #timedatecolumn1 is newer than #timedatecolumn2?
Code:
days_between($$#timedatecolumn1, $$#timedatecolumn2) >#0
|
No.
I assume either date can be undefined.
This one works because ISO formatted dates are comparable as strings as long as the dates are in the same timezone.
Code:
program:
d1 = $$#mydate;
d2 = $$date;
if d1 == 'None' || d2 == 'None' then return '' fi;
if d1 < d2 then 'yes' fi
An alternate way that uses timestamps, which should work with differing timezones but might have problems with dates previous to "the epoch" (1970 IIRC):
Code:
program:
d1 = $$#mydate;
d2 = $$date;
if d1 == 'None' || d2 == 'None' then return '' fi;
d1 = format_date($#mydate, 'to_number');
d2 = format_date($date, 'to_number');
if d1 <# d2 then 'yes' fi
Or a Python template that works with timezones:
Code:
python:
def evaluate(book, context):
d1 = book.get('#mydate')
d2 = book.get('timestamp')
if d1 is None or d2 is None:
return '' # return no if either date isn't defined
return 'Yes' if d1 < d2 else ''