STR_DATE

Returns a string containing the current time and/or date information according to a format string.

Format

STR_DATE (Format String)

Argument

 
Note:  
All of the formatting directives described below are supported on non-Windows platforms, but some are not supported on Windows. If the specified formatting directive is not supported, then the function will simply return the input string.
 
 
Text string that uses the formatting directives listed below. If you supply an empty string (""), it defaults to "%d %b %Y %H:%M".
The available formatting directives (expressed as current date, time or time zone) are:
Format String
Description
Supported on Windows (Y/N)
%a
Abbreviated weekday name
Y
%A
Full weekday name
Y
%b
Abbreviated month name
Y
%B
Full month name
Y
%c
Date and time as %a %b %d %H:%M:&S %Y
Y
%C
Century number (the year divided by 100 and truncated to integer) as a decimal number (00-99)
N
%d
Day of month (01-31)
Y
%D
Date as %m/%d/%y
N
%e
Day of month (1-31: single digits are preceded by a blank space)
N
%h
Abbreviated month name
N
%H
Hour (00-23)
Y
%I
Hour (01-12)
Y
%j
Day number of year (001-366)
Y
%m
Month number (01-12)
Y
%M
Minute (00-59)
Y
%p
Equivalent of either AM or PM
Y
%r
Time as %I:%M:%S [AM|PM]
N
%R
Time as %H:%M
N
%S
Seconds (00-61), allows for leap seconds
Y
%T
Time as %H:%M:%S
N
%U
Week number of year (00-53), Sunday is first day of week one
Y
%y
Year within century (00-99)
Y
%Y
Year as century and year (for example, 1986)
Y
%Z
Time zone name or no characters if no time zone exists
Y

Windows Only

If # flag is used as prefix to any formatting code, the meaning of the format changes as described below:
 
Format code
Meaning
%#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z, %#%
# flag is ignored.
%#c
Long date and time representation, appropriate for current locale. For example: "Tuesday, March 14, 1995, 12:41:29".
%#x
Long date representation, appropriate to current locale. For example: "Tuesday, March 14, 1995".
%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y
Remove leading zeros (if any).

Examples

The following function returns the current date and time in the stated argument format (January 5, 1998, is the current date):
 
Function
STR_DATE("%Y %m %d, %H:%M:%S")
Result
1998 01 05, 19:55:48
The following function returns the current date and time in the underlying argument format (January 5, 1998 is the current date):
 
Function
STR_DATE("%c")
Result
Mon Jan 5 10:35:01 1998
The following function returns the current date and time in the default format (January 5, 1998 is the current date):
 
Function
STR_DATE("")
Result
05 Jan 1998 13:22
The following function simply returns the input string, if the specified directive is invalid/not supported:
 
Function
STR_DATE("ABC%D")
Result
ABC%D