Share this page

# Configure the Date/Time Functions

This task describes how to configure the Set Relative Date/Time and the Set Date/Time Relative to functions.

In this topic:

## Prerequisite: Select a date/time function

1. In the Data Model Editor, expand a rule.

2. Click inside the function field (fx) of a response column and select one of the following functions:

   1. Set relative date/time. The date and/or time value is calculated by adjusting the date/time when the request was received, using an Offset that you define.

   2. Set date/time relative to. The date and/or time value is calculated by adjusting a specified date/time, using an Offset that you define. This function requires you to select a source column that contains the date/time to be adjusted.

      Note:

      If the function row is not displayed, from the View Options menu, select Functions.

      Dynamic data functions are available for lowest level headers only. Complex headers that include lower level headers under them are displayed in italic text (header). To display lower level headers, double-click the column header.

Back to top

## Configure the function

The output of the date/time function is configured as follows:

- Offset. Defines the modification that you want to make to the source date/time. Enter the offset into each cell under the date/time function.

  If the offset is not specified for a particular cell or is in an incorrect format, an offset of 0 seconds is used.

- Format. Defines the format of the output. The resulting date/time that is output to the message response is formatted according to one of the following:

  - The XSD type of the source column.
  - The custom format that you define for the output of the function.

Example: For example, -1:25:00#hh:mm indicates the following:

- an offset of -1 hours and 25 minutes (1 hour 25 minutes earlier than source time)

- a custom format for the output time, such as 07:15

For details on configuring the offset and custom formats, see below.

Back to top

## Configure the offset

The Offset is formatted according to the following:

[-][d.]hh:mm:ss[.ff]

where:

- Items in square brackets ([ and ]) are optional
- Colons and periods (: and .) are literal characters
- "-" (optional) indicates a negative time (a time earlier than the source time)
- "d" optional days
- "hh" mandatory hours, ranging from 0 to 23
- "mm" mandatory minutes, ranging from 0 to 59
- "ss" mandatory seconds, ranging from 0 to 59
- "ff" optional fractional seconds, consisting of 1 to 7 decimal digits

Example:

- -54.12:00:59.1234567
- 0:00:00.001
- 365.0:00:00

Note: If you are using the set relative date/time function, the resulting date is generated according to the UTC+0 time zone.

Examples:

You are located in UTC-8 and have created a function with an offset of +1 day.

At 20:00 (8:00 P.M.), the generated relative time will be 4:00 (4 A.M.) the day after tomorrow, calculated as follows:

20:00(today) + 1 day (your requested offset) + 8 hours (to adjust for your time zone) = 4:00 (the day after tomorrow)

To maintain the same date/time as your time zone, adjust for the difference using the offset.

For example, if you are located in UTC-8 and you want to define +1 day offset, you must also subtract 8 hours, as follows:

16:00:00#dd-MM-yyyy# (where 16:00:00 represents 1 day - 8 hours)

For an offset of +1 day, if you are located in the UTC+2 time zone:

1:02:00:00#dd-MM-yyyy# (where 1:02:00:00 represents 1 day + 2 hours)

Back to top

## Configure the date/time format

Service Virtualization can set the format based on autodetection of the XSD type, or by a custom format that you enter.

XSD Type

Service Virtualization can auto-detect the following XSD date/time types

- xsi:date - "yyyy-MM-dd" (Example of output: 1984-11-28)
- xsi:time - "HH:mm:ss" (Example of output: 23:59:59)
- xsi:dateTime - "yyyy-MM-ddThh:mm:ss" (Example of output: 2001-12-13T10:15:33)

If detected, the format of the output of the date/time function is based on the XSD type, provided that you have not defined a custom format.

No other formats, including JSON date/time formats, can be detected, as their internal type is xsi:string. If the application cannot detect the format from the element's type, xsi:dateTime's format is used by default. If you want to specify other output formats, you can define a custom format.

Custom Format

To configure a custom format, enter the following into each cell under the date/time function:

Offset#CustomFormat

You define a custom format using the following:

- "d" - The day of the month, from 1 through 31.
- "dd" - The day of the month, from 01 through 31.
- "f" .. "fffffff" - Fractions of a second, number of "f" characters specifies number of digits to print.
- "h" - The hour, using a 12-hour clock from 1 to 12.
- "hh" - The hour, using a 12-hour clock from 01 to 12.
- "H" - The hour, using a 24-hour clock from 0 to 23.
- "HH" - The hour, using a 24-hour clock from 00 to 23.
- "m" - The minute, from 0 through 59.
- "mm" - The minute, from 00 through 59.
- "M" - The month, from 1 through 12.
- "MM" - The month, from 01 through 12.
- "s" - The second, from 0 through 59.
- "ss" - The second, from 00 through 59.
- "tt" - The AM/PM designator.
- "yyyy" - The year, four digit number.
- regular characters (all characters except the ones mentioned above) - generated "as is". To generate a character that has a special meaning (is part of one of the custom formats above, such as “s”), place a '\' before it.

## Examples

Click on this thumbnail for a cheat sheet for relative date/time functions.

Example:

If today's date is December 10, 2012:

- To generate yesterday's date: -1.00:00:00#yyyy-MM-dd

  Result: The output is 2012-12-09.

- To generate today's date: : 0#MM/dd/yyyy

  Result: The output is 12/10/2012.

- To generate the date 1 week from today: 7.00:00:00#MM/dd/yyyy

  Result: The output is 12/17/2012.

Back to top

See also:

- Rule Functions

https://admhelp.microfocus.com Service Virtualization 8942
Tips to improve your search results... Service Virtualization Help Center SV Help 5.4-5.4.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: