When you work with date, you may use the functions that process dates.
In these functions, sometimes a format pattern of a date or any number must be defined. Also locale can have an influence to their formatting.
For detailed information about date formatting and/or parsing see Data and Time Format.
For detailed information about locale see Locale.
Note | |
---|---|
Remember that numeric and date formats are displayed using system
value Locale or Locale specified in the For more information on how Locale may be changed in the |
Here we provide the list of the functions:
date dateadd(
date arg, <numeric type> amount, unit timeunit)
;
The dateadd(date, <numeric type>, unit)
function accepts three arguments: the first is date, the second is
of any numeric data type and the last is any time unit. The unit
can be one of the following: year
,
month
, week
,
day
, hour
,
minute
, second
,
millisec
. The unit must be specified as a
constant. It can neither be received through an edge nor set as
variable. The function takes the first argument, adds the amount
of time units to it and returns the result as a date. The
amount
and time unit
are
specified as the second and third arguments, respectively.
int datediff(
date later, date earlier, unit timeunit)
;
The datediff(date, date, unit)
function
accepts three arguments: two dates and one time unit. It takes
these arguments and subtracts the second argument from the first
argument. The unit can be one of the following:
year
, month
,
week
, day
,
hour
, minute
,
second
, millisec
. The unit
must be specified as a constant. It can be neither received
through an edge nor set as variable. The function returns the
resulting time difference expressed in time units specified as the
third argument. Thus, the difference of two dates is expressed in
defined time units. The result is expressed as an integer number.
Thus, date(2008-06-18, 2001-02-03, year)
returns 7
. But, date(2001-02-03,
2008-06-18, year)
returns -7
!
date random_date(
date startDate, date endDate)
;
The random_date(date, date)
function
accepts two date arguments and returns a random date between
startDate
and endDate
. These
resulting dates are generated at random for different records and
different fields. They can be different for both records and
fields. The return value can also be startDate
or endDate
. However, it cannot be the date
before startDate
nor after
endDate
. Remember that dates represent 0 hours
and 0 minutes and 0 seconds and 0 milliseconds of the specified
day, thus, if you want that endDate
could be
returned, enter the next date as endDate
. As
locale
, system value is used. The default
format
is specified in the
defaultProperties
file.
date random_date(
date startDate, date endDate, long randomSeed)
;
The random_date(date, date, long)
function accepts two date arguments and one long argument and
returns a random date between startDate
and
endDate
. These resulting dates are generated at
random for different records and different fields. They can be
different for both records and fields. The return value can also
be startDate
or endDate
.
However, it cannot be the date before startDate
nor after endDate
. Remember that dates
represent 0 hours and 0 minutes and 0 seconds and 0 milliseconds
of the specified day, thus, if you want that
endDate
could be returned, enter the next date
as endDate
. As locale
,
system value is used. The default format
is
specified in the defaultProperties
file. The
third argument ensures that the generated values remain the same
upon each run of the graph. The generated values can only be
changed by changing the randomSeed
value.
date random_date(
date startDate, date endDate, string format)
;
The random_date(date, date, string)
function accepts two date arguments and one string argument and
returns a random date between startDate
and
endDate
corresponding to the
format
specified by the third argument. These
resulting dates are generated at random for different records and
different fields. They can be different for both records and
fields. The return value can also be startDate
or endDate
. However, it cannot be the date
before startDate
nor after
endDate
. Remember that dates represent 0 hours
and 0 minutes and 0 seconds and 0 milliseconds of the specified
day, thus, if you want that endDate
could be
returned, enter the next date as endDate
. As
locale
, system value is used.
date random_date(
date startDate, date endDate, string format, long randomSeed)
;
The random_date(date, date, string, long)
function accepts two date arguments, one string and one long
arguments and returns a random date between
startDate
and endDate
corresponding to the format
specified by the
third argument. These resulting dates are generated at random for
different records and different fields. They can be different for
both records and fields. The return value can also be
startDate
or endDate
.
However, it cannot be the date before startDate
nor after endDate
. Remember that dates
represent 0 hours and 0 minutes and 0 seconds and 0 milliseconds
of the specified day, thus, if you want that
endDate
could be returned, enter the next date
as endDate
. As locale
,
system value is used. The fourth argument ensures that the
generated values remain the same upon each run of the graph. The
generated values can only be changed by changing the
randomSeed
value.
date random_date(
date startDate, date endDate, string format, string locale)
;
The random_date(date, date, string,
string)
function accepts two date arguments and two
string arguments and returns a random date between
startDate
and endDate
. These
resulting dates are generated at random for different records and
different fields. They can be different for both records and
fields. The return value can also be startDate
or endDate
corresponding to the
format
and the locale
specified by the third and the fourth argument, respectively.
However, it cannot be the date before startDate
nor after endDate
. Remember that dates
represent 0 hours and 0 minutes and 0 seconds and 0 milliseconds
of the specified day, thus, if you want that
endDate
could be returned, enter the next date
as endDate
.
date random_date(
date startDate, date endDate, string format, string locale, long randomSeed)
;
The random_date(date, date, string, string,
long)
function accepts two date arguments, two strings
and one long argument returns a random date between
startDate
and endDate
. These
resulting dates are generated at random for different records and
different fields. They can be different for both records and
fields. The return value can also be startDate
or endDate
corresponding to the
format
and the locale
specified by the third and the fourth argument, respectively.
However, it cannot be the date before startDate
nor after endDate
. Remember that dates
represent 0 hours and 0 minutes and 0 seconds and 0 milliseconds
of the specified day, thus, if you want that
endDate
could be returned, enter the next date
as endDate
. The fifth argument ensures that the
generated values remain the same upon each run of the graph. The
generated values can only be changed by changing the
randomSeed
value.
date today(
)
;
The today()
function accepts no argument
and returns current date and time.
date trunc(
date arg)
;
The trunc(date)
function takes one date
argument and returns the date with the same year, month and day,
but hour, minute, second and millisecond are set to 0.
long trunc(
<numeric type> arg)
;
The trunc(<numeric type>)
function takes one
argument of any numeric data type and returns its truncated long
value.
null trunc(
list arg)
;
The trunc(list)
function takes
one list argument, empties its values and returns null.
null trunc(
map arg)
;
The trunc(map)
function takes
one map argument, empties its values and returns null.
date trunc_date(
date arg)
;
The trunc_date(date)
function takes one
date argument and returns the date with the same hour, minute,
second and millisecond, but year, month and day are set to 0. The
0 date is 1970-01-01.