Service Virtualization

 View Only

  • 1.  Date Time modification in response

    Posted Apr 22, 2026 07:46 AM

    Hi ALl

    We have a request which has a date argument 

    eg  DateTime = 2026-04-22T05:15:05Z

    And response , we want to use this date and send in a 3 days advance date

    {
    "responseDateTime" : "2026-04-25T05:15:05Z"

    }

    Thanks



    -------------------------------------------


  • 2.  RE: Date Time modification in response

    Posted Apr 22, 2026 07:48 AM

    Can we use a script or a step in vsm? , can someone help with the steps. Thanks

    -------------------------------------------



  • 3.  RE: Date Time modification in response

    Broadcom Employee
    Posted Apr 22, 2026 09:32 AM

    Hi Akshit,

    You can use Magic dates, to achieve the functionality you are looking. 

    You said, the request has "DateTime = 2026-04-22T05:15:05Z". When you do the recording, your response should have magic stringed the date using.

    doDateDeltaFromRequest(yyyy-MM-dd","10D). You can change the days per your functionality.
    Please look at the documentation for more information. If you still need more help, please share your RR pairs.
    Prema 
    -------------------------------------------



  • 4.  RE: Date Time modification in response

    Posted Apr 22, 2026 10:17 AM

    Hi Prema

    Thanks for replying

    Its a get request 
    https://xyz.com:443/test?userID=1234&requestedDateTime=2026-02-25T05%3A15%3A05Z

    and then in response it looks like

    {
     "DateTime": "2026-02-25T11:30:00+00:00"
    }
    So instead of a hardcoded field in response , we want the date +3 days from the date in request.
    Also the magic date which you have shared above does it work on the type which we have in the url , as while recording devtest didnt convert it into magic string.

    Thanks
    Akshit



    -------------------------------------------



  • 5.  RE: Date Time modification in response

    Posted May 28, 2026 11:13 AM

    Hi Akshit,

    Since your datetime is coming as a query parameter in the GET request as "requestedDateTime=2026-02-25T05:15:05Z" you can reference that request component in the response using doDateDeltaFromRequest. The following will return the request datetime +3 days dynamically.

    Example:
    {
      "DateTime": "{{=doDateDeltaFromRequest(\"yyyy-MM-dd'T'HH:mm:ssX\",\"3D\")}}"
    }

    Besides, if your use-case involves dynamic date transformations, conditional responses, or complex IF/ELSE decisions, Beeceptor deep support for this. your ask can be simplied in the following syntax with Beeceptor which is a meta-style language, with dynamic helpers right inside mock responses building. i have used both Devtest and Beeceptor and this is my experience on configuration.
    {
    "responseDateTime": "{{dateAdd (queryParam 'DateTime') '{days:3}' 'iso'}}"
    }

    -------------------------------------------