$(date)
Description
This built-in function provides basic operation to manipulate date such add “adding day”, “setting hour”. This
built-in function assumes the date
parameter in the standard US date format (i.e. MM/dd/yyyy HH:mm:ss
). You might
want to consider using $(date|stdFormat|date|fromFormat)
or $(date|format|date|fromFormat|toFormat)
functions to
derive the appropriate format first before invoking other date-operational functions.
Date Format
For date/time formatting (denoted below as format
or *Format
), Nexial supports the following 3 conventions:
- Standard Java date/time formatting convention for a full range to express the desired date/time format.
- epoch
for timestamp. Use
epoch
to signify the display of date/time value in its epoch value (millisecond). informal
to express date/time information in a colloquial, non-exact manner that mimic human conversation. For example,informal
format would outputabout a minute ago
instead of00:00:57
, orabout a month and a half ago
rather than2018/08/24 00:01:32
. Theinformal
format is suitable to use in conjunction with the sound »speak(text)
command.base10time
to express time information as a base-10 decimal number. For example,10:25:30
would be converted as10.425
,14.32918
would be converted as14:19:46
.
Available Functions
$(date|stdFormat|date|fromFormat)
Convert a date
from fromFormat
to the standard format (i.e. MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|format|date|fromFormat|toFormat)
Convert a date
from the specified fromFormat
to the specified toFormat
. Check out above links
for date format.
Example
Script:
Output:
$(date|addYear|date|years)
Add years
to date
. Use negative value to denote the “subtract” intent. The specified date
is assumed in standard
format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|addMonth|date|months)
Add months
to date
. Use negative value to denote the “subtract” intent. The
specified date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|addDay|date|days)
Add days to date
. Use negative value to denote the “subtract” intent. The specified
date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|addHour|date|hours)
Add hours to date
. Use negative value to denote the “subtract” intent. The
specified date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|addMinute|date|minutes)
Add minutes to date
. Use negative value to denote the “subtract” intent. The
specified date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|addSecond|date|seconds)
Add seconds to date
. Use negative value to denote the “subtract” intent. The
specified date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|diff|date1|date2|precision)
Find the absolute difference between 2 dates (date1
and date2
) and return such value in the specified date
precision
. The possible values of precision
are YEAR
, MONTH
, WEEK
, DAY
, HOUR
, MINUTE
, SECOND
and
MILLISECOND
. The specified dates (date1
and date2
) are assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setYear|date|years)
Set the year portion of date
to the specified years
. The specified date
is
assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setMonth|date|months)
Set the month portion of date
to the specified months. The specified date
is
assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setDay|date|days)
Set the day portion of date
to the specified days. The specified date
is assumed
in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setHour|date|hours)
Set the hour portion of date
to the specified hours. The specified date
is
assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setMinute|date|minutes)
Set the minute portion of date
to the specified minutes. The specified
date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setSecond|date|seconds)
Set the second portion of date
to the specified seconds. The specified
date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
).
Example
Script:
Output:
$(date|setDOW|date|day)
Derive the “day of the week” for a given date. The specified date
is assumed in standard format (MM/dd/yyyy HH:mm:ss
or MM/dd/yyyy
). Use the days
parameter to set the day of the week. As a convenience, both 0
and 7
represent
Sunday, while 6
represents Saturday. Since there are only 7 days in a week, any integer value outside the range of 0
through 7 would be considered as value. For example, March 21th 2013 is a Thursday. $(date|setDOW|03/21/2013|1)
would
yield 03/18/2013
, which is a Monday.
Example
Script:
Output: