06-29-2022 06:52 AM
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
Solved! Go to Solution.
06-29-2022 08:00 AM
Than I go back to my original statement. This expression will do the job:
Date.parse($Last_Updated) > Date.now().minusHours(48)
06-29-2022 07:50 AM
Moreover, the Timezone of Last_Updated is UTC as I haven’t changed it to any other timezone, may be that is creating a hurdle?
06-29-2022 08:00 AM
Than I go back to my original statement. This expression will do the job:
Date.parse($Last_Updated) > Date.now().minusHours(48)
06-29-2022 08:10 AM
Sure @bojanvelevski, I will test it out and keep you posted.
For now, I’m not seeing any data in my filter snap, may be there is no record that suffice the condition but I will manually change the data from the source system and test if this works.
As always, appreciate your help on this one too.
06-29-2022 08:56 AM
I wasn’t able to fetch any records with this criteria but that doesn’t mean this is not the solution. It is indeed and thank you @bojanvelevski for your help on this one.
Reason behind no records to be fetched was there were actually no records those were updated in the last 48 hours, I tweaked my criteria to 7 Days and found some for testing purposes and I can confirm that this worked.
Also, with Date.parse, the date format is consistent so not to worry about EST and UTC.
Something new I learned today was
Date.now().minusDays(7)
This above function helped me test the functionality for the last 7 days.
Thanks again @bojanvelevski , signing off from this thread now!
06-30-2022 06:45 AM
@bojanvelevski: I do understand that we closed this thread as we got the desired solution however putting a comment here as the next thing I’m trying to achieve is related to this functionality itself.
We were considering all records whose Last_Updated was less than 48 hrs
and then those records were set to update the Salesforce table.
After that, a scheduled job was enabled to run 4 times a day and as we are considering records updated within last 48 hrs, we are seeing duplicate records in each batch, I believe we will continue to see those as the criteria is less than 48 hours, is there a way we can filter out what was updated in the last batch and consider the brand new ones ONLY?
Thanking you in advance for your help 🙂
Regards,
Darsh