Description
The Date and Time macro is used to insert data and time values into strings generated with the Custom String generator.
The macro is an analog of the Date and Time data generator.
Syntax
The macro has the following syntax:
%TIME(MinDate, MaxDate, Format, Step, *SEQ | *RND, *xN)
Parameters
MinDate and MaxDate
Strings that specify the earliest and latest possible generated dates. The way the macro generates dates within this range depends on the *SEQ or *RND parameter. See below.
Notes:
-
MinDate must be an earlier date/time value than MaxDate.
-
MinDate and MaxDate must have the English (US) date format and the 24-hour time format, for instance,
7/19/2013 03:40:55
.
Format
A string that specifies the format of the generated date/time value. To define the format, use the following symbols:
Symbol | Description |
---|---|
d or dd | Day as a number. If you use dd , the macro will add the leading zero to the days that are less than 10. If you use d , the leading zero is not added. |
ddd | Brief day name (Mon, Tue, Wed, and so on). |
dddd | Full day name (Monday, Tuesday, Wednesday, and so on). |
M or MM | Month as a number. If you use MM , the macro will add the leading zero if the month is less than 10. If you use M , the leading zero will not be added. |
MMM | Brief month name (Jan, Feb, Mar, and so on). |
MMMM | Full month name (January, February, March, and so on). |
y or yy | Two last digits of the year, for instance, 13 for 2013 and 95 for 1995. |
yyy or yyyy | Full year (2013, 1995 and others). |
H or HH | Hours in the 24-hour time format. If you use HH , the macro will append the leading zero to the hours that are less than 10. If you use H , the leading zero is not added to the hours. |
h or hh | Hours in the 12-hour time format. Use these symbols with the tt symbols (see below). If you use hh , the macro will append the leading zero to the hours that are less than 10. If you use h , the leading zero is not added to the hours. |
m or mm | Minutes. If you use mm , the macro will append the leading zero to the minutes that are less than 10. If you use m , the leading zero is not added to these values. |
s or ss | Seconds. If you use ss , the macro will append the leading zero to the seconds that are less than 10. If you use s , the leading zero is not added to these values. |
tt | Inserts either AM or PM if your local settings support this format. Otherwise, the corresponding letters will not be inserted. |
All other symbols in the parameter are treated literally.
When specifying this parameter, remember the format that is accepted by the web application or server under test. The date/time values should be in the format that the application (server) expects, not in the format that is used on your computer.
The default value of the parameter is "M/d/yyyy HH:mm:ss"
.
Step
This parameter is used only if the *SEQ mode is selected (see below). It specifies the number of days, hours, minutes and seconds to be added to the previously generated value to get a new value. If the *RND mode is selected, the parameter is ignored and can be skipped.
The parameter value should have the format d:H:m:s
(see above).
The default parameter value is 1:12:24:48
(1 day, 12 hours, 24 minutes and 48 seconds).
*SEQ or *RND
Specifies the functioning mode for the generator:
-
*SEQ
- If this value is specified, the macro will use MinDate as the first generated value and increase it on Step to get the next generated values. -
*RND
- If this value is specified, then for each generated custom string the macro produces an arbitrary date/time value within the MinDate...MaxDate range.
*xN
Optional parameter. Specifies the number of possible repetitions of each value in series of generated strings. N is a positive number that specifies the number of repetitions: 1, 2, 3, and so on. The default parameter value is *x1
(no repetitions).
Examples
The following examples demonstrate how to use the Date and Time macro:
-
%TIME("7/12/2013 04:05:00","10/20/2013 04:05:00","MMM d, yyyy h:mm tt", 1:1:10:0)
Generates date/time values starting from July 12, 2013 and increasing each value by one day, one hour and one minute. The values have a brief month name and the 12-hour time format (AM/PM):
Jul 12, 2013 4:05 AM
Jul 13, 2013 5:15 AM
Jul 14, 2013 6:25 AM
... -
%TIME("7/12/2013 01:00:00","7/12/2014 23:00:00","dd.MM.yy HH:mm:ss", *RND)
Generates random date/time values in the range July 12, 2013 … July 12, 2014. Generated values have the format adopted in Germany and some other European countries:
08.12.13 12:53:51
09.02.14 17:03:00
17.08.13 10:11:17
... -
%TIME("7/12/2013","10/20/2013","dd-MMM-yy",*RND)
Generates random dates in the range July 12, 2013 … October 20, 2013. Generated values include only dates (no time):
18-Aug-13
17-Aug-13
17-Sep-13
... -
%TIME("03:05:30","14:05:00","HH:mm:ss", 00:10:0, *SEQ, *x2)
Generates time values starting from 03:05:30 and increasing the value by 10 minutes. Generated values include only time (no date). Each value is repeated twice in the sequence of generated custom strings:
03:05:30
03:05:30
03:15:30
03:15:30
03:25:30
03:25:30
...
Remarks
-
For more information on adding macros to custom strings, see About Custom String Generator
-
For more information on general rules used for specifying macro parameters, see Custom String Generator Rules .
See Also
Macro Reference
Custom String Generator Rules
Custom String Generator
Date and Time Generator
Using Data Generators
Generating Values