Forum Discussion

hagaib's avatar
hagaib
New Contributor
15 years ago

Date calculation in Request

Hi,

I would like to manipulate dates as parameters in my Requests. Something like: Today+20 days, or Today+1Month, etc...
I can add the "Today" date via Groovy script and update a project parameter for example, but how do I do the math (today+x days)?
How can I achieve this functionality?

Thanks,
Hagai.

2 Replies

  • Hi,

    For manipulating dates within soapui use following Groovy code lines :
    def xDay = new Date()
    xDay = xtDay + 10
    log.info xDay.toString() //added 10 days to the current date.

    And store the newly generated values in a custom property variable.

    Regards,
    ~Pradeep Bishnoi~
    http;//learnsoapui.wordpress.com
  • hagaib's avatar
    hagaib
    New Contributor
    Hi Pradeep,

    Thanks for your reply.
    I know how to do that withthe groovy and store in property.
    however, the problem I need to solve is the ability to define a way to give a flexible way to the users of the framework to populate dates in the requests.
    for example:
    one user can ask for: today+ 10days;
    Other user will ask for: today + 1Month;

    How can I invoke a mechanism (smart and nice) to calculate the date before running the request?

    Thanks,
    Hagai