Greater than or less than logic for dates

I’m a bit confused on the logic for the “<” and “>” operators for dates. Would this be a correct constraint if I want to schedule deletion for records whose created date is 30 days old?

image

What’s a way to understanding these operators for dates?

1 Like

less than X date = anything BEFORE this date
greater than X date = anything AFTER this date

2 Likes

Current date/time + 30 days will always be in the future so no, that expression would not be correct. You want anything that was created earlier than 30 days ago, so Created date ≤ current date/time +(days): -30.

1 Like

Date/time data is stored as a time-stamp, in elapsed milliseconds (since Jan 1970). So the bigger the number, the later the date.

So Date A > Date B means that Date A is later (after) Date B.

What you’re showing in your image is a comparison… i.e. you’re comparing (presumably as a search or filter constraint) the ‘created date’ of a specific item with the current date/time plus 30 days. In other words, you’re asking if the created date of the specified item is more than 30 days in the future - the answer to which will be either Yes or No.

By definition, the ‘created date’ of an item can never be in the future, so in this case the answer will always be ‘No’.

If, as you say in your question, you’re trying to ‘schedule’ a workflow to delete records once they are 30 days old, then just schedule the workflow to run 30 days after they are created, i.e. current date/time +(days) 30

Or, if you’re trying to find items retrospectively and delete them that way in a single workflow, you can use this constraint on your search:

Created Date < Current Date/Time +(Days) -30

3 Likes

I just had to do the opposite to get my worklflow to work as expected, I’l pretty sure it was not the case before. I feel a bit crazy now