Email alert: comparing datetime.date to str

Hi,

I’m trying to send an alert when today’s date equals or is greater than a certain datetime.date field. The nowdate() is a string, so comparing the two fields throws an error, and I can’t simply cast the datetime.date into a string and have the correct comparison.

I also can’t access the datetime modules to do an accurate comparison, or get datetime.datetime.now().date.

Is there a way to either:
a) through the UI, set up a >= field for dates, sending one email per day or one per week?
b) accurately compare these dates in the conditions?

Thanks.

1 Like

Hi @alec_ruizramon1,

use the get_datetime() to get the datetime object

Thanks, Makarand

@makarand_b thanks for responding. get_datetime() throws and invalid condition error (even when comparing it to itself i.e. get_datetime() == get_datetime()

@alec_ruizramon1,

I tried the same I got the result as False (due to the difference in microseconds), please check the screenshot.

Thanks,

Sorry, I meant that in the Email Alert document it won’t allow me to save with get_datetime() as a condition! Likely as part of the input scrubbing to avoid unwanted/unsafe code being executed in the alerts.

1 Like