I am trying to compare two dates one is stored in DB (lets call it dbValue) and another one is from now ( ).
Now, where I have :
dbValue: 10/02/2021 09:00 AM
now: 10/1/2021 9:18 AM EDT
it gives me true
dbValue: 09/30/2021 09:00 AM
it again gives me true
Not sure what's the issue, please help me.
Discussion posts and replies are publicly visible
Is your dbValue a local variable or a rule input of date and time type? If its a rule input of the same data type as now() there shouldn't be an issue if not then it is comparing a text with a timestamp which will not give desired output. Try converting it using todatetime before comparison and it should work.
todatetime("10/02/2021 09:00 AM") < now()
Thanks it worked, I had dbValue stored in text format.
Also to note, the todatetime() function applies a timezone offset, "todatetime("10/02/2021 09:00 AM")" in eastern time will return 5 AM ET. To return the actual text value of the time, apply gmt() as:
gmt(todatetime("10/02/2021 09:00 AM"))
It is also strongly encouraged to use proper data types when storing to the DB, storing such things as datetime values as text will most certainly present issues down the road.
© 2021 Appian. All rights reserved.