Dynamic date value in URL or request body

We can generate dynamic date values in URLs or HTTP request content. This can be useful for web services that require a date value to be entered as part of the request body for a HTTP POST, for example:

… <StartDate>2013-11-27</StartDate> ...

Rather than entering a fixed value date, we can use the following notation to generate values based on today’s date/time:

… <StartDate>{datetime;yyyy-MM-dd}</StartDate> …

Please note that other format values are also possible. Additionally, we can use offsets to calculate different values.

This notation will then be replaced with an actual value, by taking the date/time from today, and calculating/formatting the appropriate value.

Notation

The generic format for using dynamic dates is:

{datetime;format;offset;skipdates}

  • format: defines the date/time formatting to be used, using identifiers for day/month/year/hours/minutes/seconds: dd, MM, yyyy, HH, mm, ss
  • offset: value that defines the day offset to be used, relative to the current date and time. Positive values calculate dates in the future; negative values calculate dates in the past.
  • skipdates: skips specific dates (defined in format yyyy-MM-dd) or any weekend day (defined as 'w')

Examples

{datetime;MM/dd/yyyy;1}        “tomorrow” in American format

{datetime;dd-MM-yyyy;-1}       “yesterday” in Dutch format

{datetime;MM/dd/yyyy;3;W}   three days from today, but skip weekend days

{datetime;MM/dd/yyyy;1;W,2013-12-25,2014-01-01}   three days from today, but skip weekend days, Christmas Day 2013 and New Year's Day 2014

{datetime;yyyy-MM-ddTHH:mm:ss"GMT+00:00"}         “now” in ISO format

Offsets for hours and minutes are also possible.

A final example on how this would look in an actual URL that is specified in a monitor (generating two dates: today + 7 days, and today + 14 days):

http://www.mysite.com/Search?startDate={datetime;yyyy-MM-dd;7}&endDate={datetime;yyyy-MM-dd;14}

Note: You can use this notation in the Request Body content for an HTTP/Webservice monitor as well.