Calculate date base on input date and minutes or hour difference

Hello Webmethods Expert,

I am trying to build a service which to scan all the transaction for the past 1 hour or 30 minutes until now.
Basically for this service i have 2 inputs:

  • start_date = last 1 hour or 30 minutes from now
  • end_date = current date time

For the “end_date”, i can use: pub.date:getCurrentDateString
But i am still doubt, how can i construct “start_date” which is current datetime minus 1 hour or 30 minutes from now?

I don’t think the service pub.date:calculateDateDifference can do this either.

Any idea on built in services to construct the “start_date”?

Appreciate any help.

Thank you,
Fanny T

1 Like

Hi,

You should look into the “webMethods Integration Server Built-In Services Reference” manual.

pub.datetime:increment

WmPublic - Increments or decrements a date and time by a specified amount of time.

Happy coding.

1 Like

Hi Gerardo,

Looks like i am still referring to the Software AG built in Services Reference Version 9.5 SP1.
I don’t see the incrementDate in this document.

Since i am using Version 10.3, i can see this service in WmPublic.
pub.date:incrementDate.

Many thanks for pointing this service.

Best Regards,
Fanny T

Hi,
There are a few steps to build a flow service which you may need, like below:

  1. build a service with
    service Input = minutes_offset
    service output = start_date, end_date

  2. invoke pub.date:getCurrentDate

  3. invoke pub.date:formatDate, to get yyyy(year), MM(month), dd(day), HH(hour), mm(mins)

  4. invoke pub.math:addInts, add mm with minutes_offset (30mins or 60 mins)

  5. invoke pub.date:formatDate to get end_date, pattern = yyyy-MM-dd HH:mm

  6. invoke pub.date:dateTimeBuild to get start_date, pattern = yyyy-MM-dd HH:mm