cancel
Showing results for 
Search instead for 
Did you mean: 

Issue while adding days to date field in mapper

amardeep2021
New Contributor III

Hi,

I have a scenario where I am trying to increment a date field by 7 days in loop till it reaches another date value. I see data type as date for the field I am working, still while using plusDays(7) function I am getting error. I couldn’t date.parse() as it’s already a date field. I can’t convert to string as I need to add days to the same field in loop. Does anyone know how to overcome this issue? Please advise.

PFA of screenshot from mapper snap.

Regards,
Amar.
Screen Shot 2022-01-19 at 3.39.58 PM

9 REPLIES 9

bojanvelevski
Valued Contributor

Hey @amardeep2021,

Try parsing a stringified version of the date, like this:

Date.parse($weekof.toString()).plusDays(7)

amardeep2021
New Contributor III

Thanks Bojan. I am able to use the expression suggested to add 7 days to date value. But it comes up with timestamp as well which I should not have. To remove timestamp I tried slice and substr fucntions both not working because of data type. Do you know how to remove timestamp from this? PFA of screenshot.

Also I want to achieve something like below.

If A <B
A = A + 7 days

Endif

Any tip for the above 2 would be helpful.

Regards,
Amar.

Screen Shot 2022-01-20 at 5.54.11 AM

bojanvelevski
Valued Contributor

If you’re comparing this field with another, than parse the other field as well, do the comparison and use the .toLocaleDateString() function after, on both fields. That will help you get the date parts only.

Regards,
Bojan

amardeep2021
New Contributor III

Thanks Bojan. This works to trim timestamp.

Do you know how to increment the same date in loop till it reaches a specific date field value? Please let me know if you have any tips.

Regards,
Amar.