Layer7 API Management

Expand all | Collapse all

How can I get the difference(no. of days) between two dates coming as parameter in url?

Jump to Best Answer
  • 1.  How can I get the difference(no. of days) between two dates coming as parameter in url?

    Posted 05-28-2018 06:30 AM

    I have two dates as input parameters, I want to get the number of days in between them in CA API Gateway.

     

    Please help.



  • 2.  Re: How can I get the difference(no. of days) between two dates coming as parameter in url?
    Best Answer

    Posted 05-29-2018 08:26 AM

    With xpath substract the two dates in dateTime format to get the duration. Next use a xpath function to calculate the duration in days.



  • 3.  Re: How can I get the difference(no. of days) between two dates coming as parameter in url?

    Posted 05-29-2018 07:11 PM

    In addition to Remco Dekker 's comment, the set context variable assertion can set date/time type of variable. Then you can use ${variable.seconds} to get the value of the variable in second timestamp format. Then you can use xpath to calculate the difference of the seconds and divide by 3600*24 to turn to days.