cancel
Showing results for 
Search instead for 
Did you mean: 

How to add number of days in Current Date in CPI PI ?

dhairya
Explorer

Hello guys,

There is a requirement where i have to compare a particular date in payload with Current date plus 5 days in CPI PI mapping.

It seems to be very difficult to get current date + 5 via graphical mapping.

So am trying to write a custom function(Groovy Script) inside mapping to get Current Date + 5. I am new to CPI and groovy script so can any one guide me here to achieve this result ?

Thanks & Regards,

Dhairya

former_member813530
Discoverer
0 Kudos

Hi Dhairya,

Can you please show me how you use this code in your CustomFunc inside graphical mapping provided by Subhojit. It will be really helpful.

Date curdatejp = new Date() + 5

curdatejp.format("yyyyMMdd")

Thanks,

Amber

Accepted Solutions (1)

Accepted Solutions (1)

subhojit_saha2
Participant

Date curdatejp = new Date() + 5
curdatejp.format("yyyyMMdd") // yyyyMMdd formats the date in the way you want like 20190730, you can set your own format based on requirement.

With Regards,

Subhojit

dhairya
Explorer

Thanks Subhojit.

I am able to get the desired result now.Cheers

M4rtin
Explorer
0 Kudos

Hi subhojit.saha2, can you please tell me how its done with minutes in a datetime? Is used

${date:now:YYYY-MM-dd'T'HH:mm:ss'Z'} to create Exchange Property in content modifier and need to reduce it with 15min. Do i need a Script or is it possible within the Value-Field?

Kind regards,

Martin

Answers (1)

Answers (1)

subhojit_saha2
Participant
0 Kudos

Welcome Dhairya.