Current Date Variables

Applies to LoadComplete 4.97, last modified on May 20, 2019

The Current Date variable holds the current date and/or time in the specified format. You can use it to substitute dates in recorded requests for the current date and/or time, for example:

GET /report?date=Oct+4%2C+2010 HTTP 1.1

Recorded request with a hard-coded date

GET /report?date=@Today HTTP 1.1

Parameterized request

You can also use a Current Date variable combined with constants, incremental variables or random variables of the Date type to specify the custom date range in request parameters. For more information about using variables in requests, see About Variables.

We recommend that you select a variable whose data type matches the parameter data type. If LoadComplete fails to convert the variable value to the parameter data type, the test server may raise an error.

Parameters

Current date variables have the following parameters:

Name

The variable name, which will be used to refer to this variable in request parameters. The name can include only letters (A..Z, a..z), digits (0..9) or underscores ( _ ) and must be unique within the project.

Format

The date and/or time format. By default, the variable uses the short date format that is specified in your operating system’s Regional and Language Options. To use a custom format, specify the appropriate format string. For a list of date and time format specifiers that can be used in the format string, see the Date Format Specifiers section below.

LoadComplete automatically applies URL-encoding to variable values before inserting them into a GET or POST request. That is, spaces are encoded as +, commas (,) - as %2C, slashes (/) - as %2F, and so on. For example, the Oct 4, 2010 value will be substituted for Oct+4%2C+2010.

Time offset (hours)

By default, the variable value contains the time that matches the local time set on the computer (see below). You use Time offset to add or subtract hours from this time (to subtract hours, specify a negative value).

Using this functionality, you can easily adjust the generated time to the time zone expected by the server. For instance, if your time zone is GMT-05:00 (Eastern US & Canada) and the tested server requires time in GMT 00:00, set Time offset to +5. Similarly, if your time zone is GMT+01:00 (Amsterdam, Berlin, Bern) and the server needs time in GMT 00:00, set  -1.

About Generated Values

To generate a variable value, LoadComplete uses the current date and time set on the computer on which the simulated virtual user is “working”. If you use the Remote Agent to simulate virtual users on a remote machine, the time generated for users working on that remote computer will match the remote computer’s time, not the time of the LoadComplete computer.

To adjust the generated time to the time expected by the server, use the Time offset property.

Date and Time Format Specifiers

Standard Format Specifiers

The following table lists specifiers that correspond to standard date and time formats. These formats are specified by the Regional and Language Options in the Windows Control Panel.

Specifier Description Example for US English
c Date in the short date format plus time in the long time format. 4/23/2007 10:39:55 AM
ddddd Date in the short date format. 4/23/2007
dddddd (plus any number of additional d characters) Date in the long date format. Monday, April 23, 2007
t Time in the short time format. 10:39 AM
tt Time in the long time format. 10:39:55 AM

Date Format Specifiers

To format a date in a specific manner, you can construct a custom format string using the following specifiers:

Specifier Description Example for US English
d Day of the month, without the leading zero for one-digit days (1 through 31). 4
25
dd Day of the month as a two-digit number with the leading zero if required (01 through 31). 04
25
ddd The abbreviated name of a day of the week, as defined by your operating system’s Regional and Language Options. Mon
Tue
dddd The full name of a day of the week, as defined by your operating system’s Regional and Language Options. Monday
Tuesday
m Month as a number, without the leading zero for one-digit month numbers (1 through 12). 2
11
mm Month as a two-digit number with the leading zero if required (00 through 12). 02
11
mmm The abbreviated name of a month, as defined by your operating system’s Regional and Language Options. Jan
Feb
mmmm (plus any number of additional m characters) The full name of a month, as defined by your operating system’s Regional and Language Options. January
February
y or yy Year as a two-digit number with the leading zero if required (00 through 99). 08
93
yyy or yyyy (plus any number of additional y characters) Year as a four-digit number. 2008
1993
/ Date separator, as defined by your operating system’s Regional and Language Options. /

Time Format Specifiers

To format a time value in a specific manner, you can construct a custom format string using the following specifiers:

Specifier Description Example for US English
h Hour without the leading zero for one-digit hours. If the AM/PM, A/P or AMPM specifier is used, the hour is represented in the 12-hour format (1 through 12), otherwise in the 24-hour format (00 through 23). 9
14
hh (plus any number of additional h characters) Hour as a two-digit number with the leading zero if required. If the AM/PM, A/P or AMPM specifier is used, the hour is represented in the 12-hour format (01 through 12), otherwise in the 24-hour format (00 through 23). 09
14
m or n Minutes without the leading zero for one-digit minutes (0 through 59). 9
34
mm (plus any number of additional m characters)

nn (plus any number of additional n characters)
Minutes as a two-digit number with the leading zero if required (00 through 59). 09
34
s Seconds without the leading zero for one-digit seconds (0 through 59). 5
47
ss (plus any number of additional s characters) Seconds as a two-digit number with the leading zero if required (00 through 59). 05
47
z Milliseconds without the leading zero (0 through 999). 15
374
zzz (plus any number of additional z characters) Milliseconds as a three-digit number with the leading zeros if required (000 through 999). 015
374
AM/PM or am/pm Inserts AM or am if the time is before noon and PM or pm if the time is after noon. AM
pm
A/P or a/p Same as AM/PM, but uses A and P instead of AM and PM. a
P
AMPM or ampm The “before noon” or “after noon” designator, as specified in the Regional and Language options. AM
PM

Note:

If the AM/PM, A/P or AMPM modifier is used, the hour is formatted in the 12-hour format rather than 24-hour format.

 
: Time separator, as defined by your operating system’s Regional and Language Options. :

Other Specifiers

The table below lists other specifiers that can be used in the Format parameter:

Specifier Description
'mmm' or "mmm" The value inside single or double quotes is inserted into the resulting string as is. So, you can add characters used as specifiers (such as d or m) to the string.

To insert a quotation mark (") in the resulting string, use '"'. Similarly, to insert an apostrophe (') into the resulting string, use "'".

Any other characters are inserted to the formatted string as is.

Remarks

As you can notice, m and mm are used as both month and minute specifiers. Their meaning is determined on the basis of the context in which the specifier is used:

  • When used after a year or day specifier, m and mm are treated as month specifiers.

  • When used after an hour specifier, m and mm are treated as minute specifiers.

To avoid confusion, you can use n and nn as minute specifiers, or use uppercase M and MM for months and lowercase m and mm for minutes.

Examples

Below are some examples of custom date and time format strings and the corresponding formatted date and time values for US English.

Format String Result in US English Notes
M/d/yyyy 10/4/1993 US short date format (same as ddddd)
MM/dd/yyyy 10/04/1993  
MM/dd/yy 10/04/93  
dddd, MMMM dd, yyyy Monday, October 04, 1993 US long date format (same as dddddd)
dddd, MMMM dd, yyyy hh':'nn':'ss AM/PM Monday, October 04, 1993 04:32:07 AM Full date and time format (with long date and time)
MMMM dd, yyyy October 04, 1993  
yyyy-MMM-dd 1993-Oct-04  
yyyy-MM-dd 1993-10-04  
dd-MMM-yy 04-Oct-93  
dd.MM.yyyy 04.10.1993  
MMMM, yyyy October, 1993 Month of the year
MMMM d October 4 Day of the month
d MMMM yyyy 4 October 1993  
yyyy-MM-ddTHH':'nn':'ss 1993-10-04T14:32:07 Sortable date and time (ISO 8601 format)
yyyy-MM-ddTHH':'nn':'sszzz 1993-10-04T14:32:07152 Sortable date and time with milliseconds
ddd MMM dd hh':'mm':'ss yyyy Mon Oct 04 14:32:07 1993  

See Also

Constant Variables
Random Variables
Incremental Variables

Highlight search results