Date Functions
Date functions allow you to retrieve information on the date and manipulate the date display.
Date functions include:
GetDay function
The GetDay function gets the day (1 to 31) of the date expression.
Syntax:
GetDay(date expression)
Example:
GetDay("02/07/2006 12:57:20") = 2
GetMonth function
The GetMonth function gets the month (1 to 12) of the date expression.
Syntax:
GetMonth(date expression)
Example:
GetMonth("02/07/2006 12:57:20") = 7
GetYear function
The GetYear function gets the year of the date expression.
Syntax:
GetYear(date expression)
Example:
GetYear("02/07/2006 12:57:20") = 2006
GetDayOfWeek function
The GetDayOfWeek function gets the day of the week (1 to 7, where 1 denotes Sunday) of the date expression.
Syntax:
GetDayOfWeek(date expression))
Example:
GetDayOfWeek("02/07/2006 12:57:20") = 1
GetHour function
The GetHour function gets the hour (0 to 23) of the date expression.
Syntax:
GetHour(date expression)
Example:
GetHour("02/07/2006 12:57:20") = 12
GetMinute function
The GetMinute function gets the minute (0 to 59) of the date expression.
Syntax:
GetMinute(date expression)
Example:
GetMinute ("02/07/2006 12:57:20") = 57
GetSecond function
The GetSecond function gets the second (0 to 59) of the date expression.
Syntax:
GetSecond(date expression)
Example:
GetSecond ("02/07/2006 12:57:20") = 20
Age function
The Age function gets the age calculates from the current date/time, including the year (for example, 31 and a half years old = 31.5) of the date expression.
Syntax:
Age(date expression)
Example:
Age ("31/01/1973") = 33.5
Now function
The Now function gets the current date/time of the machine running the Plan Interpreter.
Syntax:
Now()
Example:
Now() = "02/07/2006 12:57:20"
FormatDate function
The FormatDate function formats the date in expression1 according to the format specification in expression2.
expression1 should be a Date (from the data), a literal date, or a variable (data type: date).
Notes:
The format of the date from the data is locale specific; meaning it will use the regional date setup on your system to read Month vs. Day.
Literal dates only must be formatted as #dd/mm/yyyy# or #dd/mm/yy# and must use a leading zero when necessary for single digits. For example: July 4, 2010 would be entered as #04/07/2010#
Dates must use a delimiter between Month, Day and Year. The following delimiters are supported: / (forward slash), \ (back slash), – (dash) and . (period).
Syntax:
FormatDate(expression1, expression2)
Example:
The following example shows how to format a Date literal:
FormatDate(#27/06/2006#, "dddd, MMMM dd, yyyy") = "Tuesday, June 27, 2006"
The following example shows how to format a variable input (Data Source field):
FormatDate(|->[Birthday], "dddd, MMMM dd, yyyy")
The following table shows the characters that can be used to format the date and the resulting date format:
Option |
Description |
---|---|
d |
Displays the day as a number without a leading zero (for example, 1). |
dd |
Displays the day as a number with a leading zero (for example, 01). |
ddd |
Displays the day as an abbreviation (for example, Sun). |
dddd |
Displays the day as a full name (for example, Sunday). |
M |
Displays the month as a number without a leading zero (for example, January is represented as 1). |
MM |
Displays the month as a number with a leading zero (for example, 01/12/01). |
MMM |
Displays the month as an abbreviation (for example, Jan). |
MMMM |
Displays the month as a full month name (for example, January). |
y |
Displays the year number (0-9) without leading zeros. |
yy |
Displays the year in two-digit numeric format with a leading zero, if applicable. |
yyy |
Displays the year in three-digit numeric format. |
yyyy |
Displays the year in four-digit numeric format. |
h |
Displays the hour as a number without leading zeros using the 12-hour clock (for example, 1:15:15 PM). |
hh |
Displays the hour as a number with leading zeros using the 12-hour clock (for example, 01:15:15 PM). |
H |
Displays the hour as a number without leading zeros using the 24-hour clock (for example, 1:15:15). |
HH |
Displays the hour as a number with leading zeros using the 24-hour clock (for example, 01:15:15). |
m |
Displays the minute as a number without leading zeros (for example, 12:1:15). |
mm |
Displays the minute as a number with leading zeros (for example, 12:01:15). |
s |
Displays the second as a number without leading zeros (for example, 12:15:5). |
ss |
Displays the second as a number with leading zeros (for example, 12:15:05). |
T |
Displays an uppercase 'A' for any hour before noon; displays an uppercase 'P' for any hour between noon and 11:59 P.M. |
TT |
Displays an uppercase 'AM' for any hour before noon; displays an uppercase 'PM' for any hour between noon and 11:59 P.M. |
t |
Displays a lowercase 'a' for any hour before noon; displays an lowercase 'p' for any hour between noon and 11:59 P.M. |
tt |
Displays an lowercase 'am' for any hour before noon; displays an lowercase 'pm' for any hour between noon and 11:59 P.M. |
Any other |
Displays as is. |