$DATETIME (get date/time)
$DATETIME acquires the current date and time according to the specified output format.
Syntax
return-value=$DATETIME(output-format)
Values
-
return-value
Specifies the name of the variable into which the acquired date and time are set.
-
output-format
Specifies an output format for the date and time, either as a constant or a variable. A constant must be enclosed in single quotation marks ('').
output-format is specified as combinations of format specifiers and character constants.
Format specifiers are symbols indicating the information to be acquired. These specifiers are expressed as a percent sign (%) paired with a single alphabetic character. Lower and upper case alphabetic characters in format specifiers are significant, with different information acquired by each. Note that, if an alphabetic character other than one defined as a format specifier character follows the percent sign (%), the specified alphabetic character is acquired.
To use a double quotation mark (") as a character constant, specify \".
The following lists the format specifiers that can be specified.
-
%a
Acquires the abbreviated day of the current date as follows:
Sun, Mon, Tue, Wed, Thu, Fri, Sat
-
%A
Acquires the conventionally written day of the current date as follows:
Sunday, Monday, Tuesday, Wednesday,
Thursday, Friday, Saturday
-
%b
Acquires the abbreviated month of the current date as follows:
Jan, Feb, Mar, Apr, May, Jun,
Jul, Aug, Sep, Oct, Nov, Dec
-
%B
Acquires the conventionally written month of the current date as follows:
January, February, March, April, May, June,
July, August, September, October, November, December
-
%d
Acquires the date as a numeric value from 01 to 31.
-
%H
Acquires the hour on the 24-hour clock as a numeric value from 00 to 23
-
%I
Acquires the hour on the 12-hour clock as a numeric value from 01 to 12.
-
%j
Acquires the number of days that have elapsed since January 1 of the current year as a numeric value from 001 to 366.
-
%m
Acquires the month as a numeric value from 01 to 12.
-
%M
Acquires the minute as a numeric value from 00 to 59.
-
%p
Acquires AM (morning) or PM (afternoon) as a character string.
-
%S
Acquires the second as a numeric value from 00 to 59.
-
%w
Acquires a one-digit number corresponding to the day of the week as a numeric value from 0 to 6, beginning with Sunday as 0, as follows:
Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3,
Thursday: 4, Friday: 5, Saturday: 6
-
%Y
Acquires the four-digit calendar year.
-
Status
The following table lists and describes the possible statuses:
Status |
Description |
---|---|
NORMAL |
Normal end |
NODATA |
— |
ERROR |
— |
Script execution interrupted |
An invalid argument was specified, or an error other than the above occurred. |
Example
The following example acquires the date and time (01:05:36 on 2015/04/01) in the format year/month/date hour:minutes:seconds:
[SET_VALUE] DATE = $DATETIME('%Y/%m/%d %H:%M:%S') MSG = 'DATE = ' + DATE $ECHO(MSG)
- Execution result:
-
DATE = 2015/04/01 01:05:36