Forum Discussion

AConner's avatar
AConner
New Contributor
6 years ago
Solved

How to send last months date in JSON reqest while doing a HTTP Post.

I saw how to add today's date dynamically into the json payload, now I want to take tat one step further and dynamically add todays date minus 30 days into the payload.  here is the example that I ha...
  • Lucian's avatar
    6 years ago

    Hi,

     

    That's quite simple:

     

    {
      "page": 0,
      "recordsPerPage": 10,
      "find": {
        "initiationDateFrom": "${= StatementDate = Calendar.getInstance(); StatementDate.add(Calendar.DAY_OF_MONTH, -30); StatementDate.format('MM/dd/yyyy')}",
        "initiationDateTo": "${= StatementDate = Calendar.instance; StatementDate.format('MM/dd/yyyy')}"
      },
      "sort": {
        "initiationDate": -1
      }
    }

    You can refer to https://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html#add(int,%20int) for more information. :smileyhappy:

     

    Let me know if it works!