cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Fetch data whose date is less than 10hrs from the existing date!

darshthakkar
Valued Contributor

Hi Team,

Iโ€™m trying to achieve a filter condition but havenโ€™t found any luck so far. My data has a field as Last_Updated which has date stored in the format 2022-06-23 03:54:45

I want to consider only those records whose date is less than 10 hours than the existing date. How can I achieve this? Shall I use a mapper or a filter snap and I would really appreciate if the logic behind this can be shared.

If the format of the date that is stored in the Last_Updated needs to be transformed as well, please let me know.
Thanks!

Regards,
Darsh

1 ACCEPTED SOLUTION

Than I go back to my original statement. This expression will do the job:

Date.parse($Last_Updated) > Date.now().minusHours(48)

View solution in original post

16 REPLIES 16

bojanvelevski
Valued Contributor

You can do something like this:

Date.parse($Last_Updated) > Date.now().minusHours(10)

Thank you @bojanvelevski, should it be > or โ€˜<โ€™ ?

Now when I reviewed your original post, yes, it should be โ€œ<โ€. You want to consider dates that are less than 10 hours than the current date.

Thatโ€™s correct and I can explain you in detail.

Letโ€™s assume, I manually execute this pipeline, the current date and time is June 29, 10:40am EST, with the filter condition, we should only consider records whose Last_updated was before 48hrs than the current date and time.

Letโ€™s assume again that 2 records have Last_Updated as June 27, 6pm EST and the difference is 48hrs (itโ€™s easy to explain if we are considering values (i.e. 24, 48, 72) that are multiple of 24) and the other records have Last_Updated as June 25, 10:40am EST, we should ONLY get those 2 records as those fall into 48hr bracket.