2018-09-05 18:19:49 -04:00
[role="xpack"]
[testenv="basic"]
[[sql-functions-datetime]]
2018-12-14 11:20:37 -05:00
=== Date/Time and Interval Functions and Operators
beta[]
{es-sql} offers a wide range of facilities for performing date/time manipulations.
[[sql-functions-datetime-interval]]
==== Intervals
A common requirement when dealing with date/time in general revolves around
2018-12-21 16:25:54 -05:00
the notion of `interval`, a topic that is worth exploring in the context of {es} and {es-sql}.
2018-12-14 11:20:37 -05:00
{es} has comprehensive support for <<date-math, date math>> both inside <<date-math-index-names, index names>> and <<mapping-date-format, queries>>.
Inside {es-sql} the former is supported as is by passing the expression in the table name, while the latter is supported through the standard SQL `INTERVAL`.
The table below shows the mapping between {es} and {es-sql}:
2018-12-21 16:25:54 -05:00
[cols="^m,^m"]
|==========================
s|{es}
s|{es-sql}
2019-01-17 03:17:58 -05:00
2+h| Index/Table datetime math
2018-12-14 11:20:37 -05:00
2+|<index-{now/M{YYYY.MM}}>
2019-01-17 03:17:58 -05:00
2+h| Query date/time math
2018-12-14 11:20:37 -05:00
| 1y | INTERVAL 1 YEAR
| 2M | INTERVAL 2 MONTH
| 3w | INTERVAL 21 DAY
| 4d | INTERVAL 4 DAY
| 5h | INTERVAL 5 HOUR
| 6m | INTERVAL 6 MINUTE
| 7s | INTERVAL 7 SECOND
2018-12-21 16:25:54 -05:00
|==========================
2018-12-14 11:20:37 -05:00
`INTERVAL` allows either `YEAR` and `MONTH` to be mixed together _or_ `DAY`, `HOUR`, `MINUTE` and `SECOND`.
TIP: {es-sql} accepts also the plural for each time unit (e.g. both `YEAR` and `YEARS` are valid).
Example of the possible combinations below:
2018-12-21 16:25:54 -05:00
[cols="^,^"]
2018-12-14 11:20:37 -05:00
|===
2018-12-21 16:25:54 -05:00
s|Interval
s|Description
2018-12-14 11:20:37 -05:00
| `INTERVAL '1-2' YEAR TO MONTH` | 1 year and 2 months
| `INTERVAL '3 4' DAYS TO HOURS` | 3 days and 4 hours
| `INTERVAL '5 6:12' DAYS TO MINUTES` | 5 days, 6 hours and 12 minutes
| `INTERVAL '3 4:56:01' DAY TO SECOND` | 3 days, 4 hours, 56 minutes and 1 second
| `INTERVAL '2 3:45:01.23456789' DAY TO SECOND` | 2 days, 3 hours, 45 minutes, 1 second and 234567890 nanoseconds
| `INTERVAL '123:45' HOUR TO MINUTES` | 123 hours and 45 minutes
| `INTERVAL '65:43:21.0123' HOUR TO SECONDS` | 65 hours, 43 minutes, 21 seconds and 12300000 nanoseconds
| `INTERVAL '45:01.23' MINUTES TO SECONDS` | 45 minutes, 1 second and 230000000 nanoseconds
|===
==== Operators
2019-01-17 03:17:58 -05:00
Basic arithmetic operators (`+`, `-`, etc) support date/time parameters as indicated below:
2018-12-14 11:20:37 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[dtIntervalPlusInterval]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dtDateTimePlusInterval]
2018-12-14 11:20:37 -05:00
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[dtMinusInterval]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[dtIntervalMinusInterval]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dtDateTimeMinusInterval]
2018-12-14 11:20:37 -05:00
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[dtIntervalMul]
--------------------------------------------------
==== Functions
2018-09-05 18:19:49 -04:00
2018-12-11 05:29:44 -05:00
beta[]
2019-02-05 11:15:26 -05:00
[[sql-functions-current-date]]
==== `CURRENT_DATE/CURDATE`
.Synopsis:
[source, sql]
--------------------------------------------------
CURRENT_DATE
CURRENT_DATE()
--------------------------------------------------
*Input*: _none_
*Output*: date
.Description:
Returns the date (no time part) when the current query reached the server.
It can be used both as a keyword: `CURRENT_DATE` or as a function with no arguments: `CURRENT_DATE()`.
[NOTE]
Unlike CURRENT_DATE, `CURDATE()` can only be used as a function with no arguments and not as a keyword.
This method always returns the same value for its every occurrence within the same query.
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[curDate]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[curDateFunction]
--------------------------------------------------
Typically, this function (as well as its twin <<sql-functions-today,TODAY())>> function
is used for relative date filtering:
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[filterToday]
--------------------------------------------------
2018-12-14 08:42:36 -05:00
[[sql-functions-current-timestamp]]
2018-12-21 16:25:54 -05:00
==== `CURRENT_TIMESTAMP`
2018-12-14 08:42:36 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP(precision <1>)
--------------------------------------------------
*Input*:
2018-12-21 16:25:54 -05:00
<1> fractional digits; optional
2018-12-14 08:42:36 -05:00
*Output*: date/time
.Description:
Returns the date/time when the current query reached the server.
As a function, `CURRENT_TIMESTAMP()` accepts _precision_ as an optional
parameter for rounding the second fractional digits (nanoseconds).
2019-02-05 11:15:26 -05:00
This method always returns the same value for its every occurrence within the same query.
2018-12-14 08:42:36 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[curTs]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[curTsFunction]
--------------------------------------------------
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[curTsFunctionPrecision]
--------------------------------------------------
2018-12-21 16:25:54 -05:00
Typically, this function (as well as its twin <<sql-functions-now,NOW())>> function is used for
relative date/time filtering:
2018-12-14 08:42:36 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[filterNow]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
[[sql-functions-datetime-day]]
2018-12-21 16:25:54 -05:00
==== `DAY_OF_MONTH/DOM/DAY`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
DAY_OF_MONTH(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the day of the month from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dayOfMonth]
--------------------------------------------------
[[sql-functions-datetime-dow]]
2018-12-21 16:25:54 -05:00
==== `DAY_OF_WEEK/DAYOFWEEK/DOW`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
DAY_OF_WEEK(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the day of the week from a date/datetime. Sunday is `1`, Monday is `2`, etc.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dayOfWeek]
--------------------------------------------------
[[sql-functions-datetime-doy]]
2018-12-21 16:25:54 -05:00
==== `DAY_OF_YEAR/DOY`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
DAY_OF_YEAR(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the day of the year from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dayOfYear]
--------------------------------------------------
[[sql-functions-datetime-dayname]]
2018-12-21 16:25:54 -05:00
==== `DAY_NAME/DAYNAME`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
DAY_NAME(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: string
.Description:
2019-01-17 03:17:58 -05:00
Extract the day of the week from a date/datetime in text format (`Monday`, `Tuesday`...).
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dayName]
--------------------------------------------------
[[sql-functions-datetime-hour]]
2018-12-21 16:25:54 -05:00
==== `HOUR_OF_DAY/HOUR`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2019-01-17 03:17:58 -05:00
HOUR_OF_DAY(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
2018-09-05 18:19:49 -04:00
2018-12-11 19:29:02 -05:00
.Description:
2019-01-17 03:17:58 -05:00
Extract the hour of the day from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[hourOfDay]
--------------------------------------------------
[[sql-functions-datetime-isodow]]
2018-12-21 16:25:54 -05:00
==== `ISO_DAY_OF_WEEK/ISODAYOFWEEK/ISODOW/IDOW`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
ISO_DAY_OF_WEEK(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the day of the week from a date/datetime, following the https://en.wikipedia.org/wiki/ISO_week_date[ISO 8601 standard].
2018-09-05 18:19:49 -04:00
Monday is `1`, Tuesday is `2`, etc.
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[isoDayOfWeek]
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
[[sql-functions-datetime-isoweek]]
2018-12-21 16:25:54 -05:00
==== `ISO_WEEK_OF_YEAR/ISOWEEKOFYEAR/ISOWEEK/IWOY/IW`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
ISO_WEEK_OF_YEAR(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the week of the year from a date/datetime, following https://en.wikipedia.org/wiki/ISO_week_date[ISO 8601 standard]. The first week
2018-12-11 19:29:02 -05:00
of a year is the first week with a majority (4 or more) of its days in January.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[isoWeekOfYear]
--------------------------------------------------
[[sql-functions-datetime-minuteofday]]
==== `MINUTE_OF_DAY`
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
MINUTE_OF_DAY(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the minute of the day from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[minuteOfDay]
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
[[sql-functions-datetime-minute]]
2018-12-21 16:25:54 -05:00
==== `MINUTE_OF_HOUR/MINUTE`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
MINUTE_OF_HOUR(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the minute of the hour from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[minuteOfHour]
--------------------------------------------------
[[sql-functions-datetime-month]]
2018-12-21 16:25:54 -05:00
==== `MONTH_OF_YEAR/MONTH`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
MONTH(datetime_exp<1>)
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2018-12-11 19:29:02 -05:00
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the month of the year from a date/datetime.
2018-12-11 19:29:02 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[monthOfYear]
--------------------------------------------------
[[sql-functions-datetime-monthname]]
2018-12-21 16:25:54 -05:00
==== `MONTH_NAME/MONTHNAME`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
MONTH_NAME(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: string
.Description:
2019-01-17 03:17:58 -05:00
Extract the month from a date/datetime in text format (`January`, `February`...).
2018-12-11 19:29:02 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[monthName]
--------------------------------------------------
2018-12-21 16:25:54 -05:00
[[sql-functions-now]]
==== `NOW`
.Synopsis:
[source, sql]
--------------------------------------------------
NOW()
--------------------------------------------------
*Input*: _none_
2019-01-17 03:17:58 -05:00
*Output*: datetime
2018-12-21 16:25:54 -05:00
.Description:
2019-01-17 03:17:58 -05:00
This function offers the same functionality as <<sql-functions-current-timestamp,CURRENT_TIMESTAMP()>> function: returns
2019-02-05 11:15:26 -05:00
the datetime when the current query reached the server. This method always returns the same value for its every
occurrence within the same query.
2018-12-21 16:25:54 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[nowFunction]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
Typically, this function (as well as its twin <<sql-functions-current-timestamp,CURRENT_TIMESTAMP())>> function is used
for relative date/time filtering:
2018-12-21 16:25:54 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[filterNow]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
[[sql-functions-datetime-second]]
2018-12-21 16:25:54 -05:00
==== `SECOND_OF_MINUTE/SECOND`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
SECOND_OF_MINUTE(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the second of the minute from a date/datetime.
2018-12-11 19:29:02 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[secondOfMinute]
--------------------------------------------------
[[sql-functions-datetime-quarter]]
==== `QUARTER`
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
QUARTER(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the year quarter the date/datetime falls in.
2018-12-11 19:29:02 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[quarter]
--------------------------------------------------
2019-02-05 11:15:26 -05:00
[[sql-functions-today]]
==== `TODAY`
.Synopsis:
[source, sql]
--------------------------------------------------
TODAY()
--------------------------------------------------
*Input*: _none_
*Output*: date
.Description:
This function offers the same functionality as <<sql-functions-current-date,CURRENT_DATE()>> function: returns
the date when the current query reached the server. This method always returns the same value for its every occurrence
within the same query.
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[todayFunction]
--------------------------------------------------
Typically, this function (as well as its twin <<sql-functions-current-timestamp,CURRENT_TIMESTAMP())>> function is used
for relative date filtering:
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[filterToday]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
[[sql-functions-datetime-week]]
2018-12-21 16:25:54 -05:00
==== `WEEK_OF_YEAR/WEEK`
2018-12-11 19:29:02 -05:00
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
WEEK_OF_YEAR(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the week of the year from a date/datetime.
2018-12-11 19:29:02 -05:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/docs.csv-spec[weekOfYear]
--------------------------------------------------
[[sql-functions-datetime-year]]
==== `YEAR`
.Synopsis:
[source, sql]
--------------------------------------------------
2019-01-17 03:17:58 -05:00
YEAR(datetime_exp<1>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
.Description:
2019-01-17 03:17:58 -05:00
Extract the year from a date/datetime.
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[year]
--------------------------------------------------
[[sql-functions-datetime-extract]]
==== `EXTRACT`
.Synopsis:
[source, sql]
2018-09-05 18:19:49 -04:00
--------------------------------------------------
2019-01-17 03:17:58 -05:00
EXTRACT(datetime_function<1> FROM datetime_exp<2>)
2018-12-11 19:29:02 -05:00
--------------------------------------------------
*Input*:
2019-01-17 03:17:58 -05:00
<1> date/time function name
<2> date/datetime expression
2018-12-11 19:29:02 -05:00
*Output*: integer
2018-09-05 18:19:49 -04:00
2018-12-11 19:29:02 -05:00
.Description:
2018-09-05 18:19:49 -04:00
2019-01-17 03:17:58 -05:00
Extract fields from a date/datetime by specifying the name of a <<sql-functions-datetime,datetime function>>.
2018-12-11 19:29:02 -05:00
The following
2018-09-05 18:19:49 -04:00
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[extractDayOfYear]
2018-09-05 18:19:49 -04:00
--------------------------------------------------
is the equivalent to
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
2018-12-11 19:29:02 -05:00
include-tagged::{sql-specs}/docs.csv-spec[dayOfYear]
2018-12-11 05:29:44 -05:00
--------------------------------------------------