Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Compare Dates in SOAP/REST Connectors

Vedanth-BK
Regular Contributor
Regular Contributor

Hello All,

Could you please help with the below?

I need to compare the date stored in user's cp1 to the current date and take an action based on the result in the CreateAccountJSON.

 Scenario- 
I have stored a date in user cp1 in the format dd-mm-yyyy. 
The condition is if the user cp1 date value is greater than the current date then I need to pass user.cp1 else current date in the format dd-mm-yyyy.
I've tried with the below syntax.

1. ${(Date.parse(user?.customproperty1).getTime()>(Calendar.instance.format('dd-MM-yyyy')))?'a':'b'}

2. ${(Date.parse('dd-MM-yyyy',user?.customproperty1).getTime()>(Calendar.instance.format('dd-MM-yyyy')))?'a':'b'}


Any help with the syntax is appreciated. 


Thank you
Vedanth B.K
12 REPLIES 12

CR
Regular Contributor III
Regular Contributor III

@Vedanth-BK  can you try like below format , may be help full

"${(user?.customproperty1.format('yyyy-MM-dd')<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Vedanth-BK
Regular Contributor
Regular Contributor

Hi @CR 
Thanks for responding,
the cp1 is considered as a string i need to parse it and then compare. 

Thank you
Vedanth B.K

CR
Regular Contributor III
Regular Contributor III

\"active\"😕"${new java.text.SimpleDateFormat('yyyy-MM-dd').format(user?.customproperty1)<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}\


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Vedanth-BK
Regular Contributor
Regular Contributor

tried the above syntax-Failed
Up to best of my knowledge, the keyword new cannot be utilized.

Thank you
Vedanth B.K

sudeshjaiswal
Saviynt Employee
Saviynt Employee

@Vedanth-BK 

You may try with,
"httpParams": "{\"IsFrozen\": \"${(user?.enddate<=(Calendar.getInstance().getTime()))?'true':'false'}\"}"

Thanks,

If you find the above response useful, Kindly Mark it as "Accept As Solution".

Vedanth-BK
Regular Contributor
Regular Contributor

VedanthBK_2-1709196352059.png

 

VedanthBK_1-1709196241023.png

 

Hello @sudeshjaiswal 
attaching a log snippet and the httpParams  above .Please let me know if iam missing anything.

 

Thank you
Vedanth B.K

sudeshjaiswal
Saviynt Employee
Saviynt Employee

Hello @Vedanth-BK,

Can you please try with the below in the createaccountjson.

 

"${(Date.parse('dd-MM-yyyy',user?.customproperty1).getTime()<=(Calendar.getInstance().getTime()))?'true':'false'}\"

OR

"${(Date.parse('dd-MM-yyyy', user?.customproperty1).getTime() >= Calendar.getInstance().getTime()) 
    ? user.customproperty1 
    : Calendar.getInstance().format('dd-MM-yyyy')
}"

 

Thanks.

If you find the above response useful, Kindly Mark it as "Accept As Solution".

Hi Sudesh
both syntaxes failed to parse.

Thank you
Vedanth B.K

sudeshjaiswal
Saviynt Employee
Saviynt Employee

Hello @Vedanth-BK,

Can you try the below sample :

${(Date.parse('dd-MM-yyyy', user?.customproperty1).getTime() > Date.now()) ? user?.customproperty1 : Calendar.getInstance().format('dd-MM-yyyy')} 


Thanks.

If you find the above response useful, Kindly Mark it as "Accept As Solution".

sudeshjaiswal
Saviynt Employee
Saviynt Employee

Hello @Vedanth-BK,

Can you please share the screenshot of the  data stored in CP1.

Thanks.

If you find the above response useful, Kindly Mark it as "Accept As Solution".

vivekmohanty_pm
Saviynt Employee
Saviynt Employee

@Vedanth-BK 

Try these -

Option 1:

${Date.parse("dd-MM-yyyy", user.customproperty1)>(new Date())?user.customproperty1:(new Date().format("dd-MM-yyyy"));}

Option 2:

${Date.parse("dd-MM-yyyy", user.customproperty1)>(java.util.Calendar.instance.time)?user.customproperty1:(java.util.Calendar.instance.time.format("dd-MM-yyyy"));}

 

Vedanth-BK
Regular Contributor
Regular Contributor

Iam able to achieve my use case thank you @vivekmohanty_pm 
thanks for inputs @sudeshjaiswal 

Thank you
Vedanth B.K