Layer7 API Management

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

    Posted May 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 May 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?

    Broadcom Employee
    Posted May 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.



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

    Posted May 23, 2022 10:57 AM
    Hi Zhijun, could you plaese specify how to use XPath to calculcate the difference between the two values in seconds?

    Thank you


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

    Posted May 23, 2022 03:46 PM
    Hi Zhijun,

    i did not understand how to use xapth (do you meane Evalute Request/Response Xpath assertion?) to calulcate the difference between the two values in seconds?
    Cuold you please better specify?

    Thank you


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

    Broadcom Employee
    Posted May 25, 2022 03:58 PM
      |   view attached
    Hi Enzo,

      Load the attached policy in a Web API service on the Gateway. Refer to the inline comments for details. Let me know if this resolves your question.

    Cheers!

    JayMac

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------

    Attachment(s)



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

    Broadcom Employee
    Posted May 25, 2022 04:01 PM
    Minor correction: the comment in the sample policy should refer to the "Format" value, not the "Formula" value.

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------