@@ -320,9 +320,9 @@ CHAR_LENGTH, CHARACTER_LENGTH, POSITION, and UNKNOWN are not currently
320
320
used: they are reserved for future use.],
321
321
BOTH, BY, CASE, CHAR_LENGTH, CHARACTER_LENGTH, CLASS, COALESCE, CONCAT,
322
322
COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DELETE, DESC,
323
- DISTINCT, ELSE, EMPTY, END, ENTRY, ESCAPE, EXISTS, FALSE, FETCH, FROM ,
324
- FUNCTION, GROUP, HAVING, IN, INDEX, INNER, IS, JOIN, KEY, LEADING, LEFT ,
325
- LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL,
323
+ DISTINCT, ELSE, EMPTY, END, ENTRY, ESCAPE, EXISTS, EXTRACT, FALSE, FETCH ,
324
+ FROM, FUNCTION, GROUP, HAVING, IN, INDEX, INNER, IS, JOIN, KEY, LEADING,
325
+ LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL,
326
326
NULLIF, OBJECT, OF, ON, OR, ORDER, OUTER, POSITION, SELECT, SET, SIZE,
327
327
SOME, SQRT, SUBSTRING, SUM, THEN, TRAILING, TREAT, TRIM, TRUE, TYPE,
328
328
UNKNOWN, UPDATE, UPPER, VALUE, WHEN, WHERE.
@@ -1697,7 +1697,8 @@ functions_returning_numerics ::=
1697
1697
SQRT(arithmetic_expression) |
1698
1698
MOD(arithmetic_expression, arithmetic_expression) |
1699
1699
SIZE(collection_valued_path_expression) |
1700
- INDEX(identification_variable)
1700
+ INDEX(identification_variable) |
1701
+ extract_datetime_field
1701
1702
----
1702
1703
1703
1704
The ABS function takes a numeric argument and
@@ -1738,11 +1739,62 @@ AND INDEX(w) = 0
1738
1739
functions_returning_datetime :=
1739
1740
CURRENT_DATE |
1740
1741
CURRENT_TIME |
1741
- CURRENT_TIMESTAMP
1742
+ CURRENT_TIMESTAMP |
1743
+ extract_datetime_part
1742
1744
----
1743
1745
1744
- The datetime functions return the value of
1745
- current date, time, and timestamp on the database server.
1746
+ The functions CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP
1747
+ return the value of the current date, time, or timestamp on the database
1748
+ server, respectively.
1749
+
1750
+ The EXTRACT function takes a datetime argument and one of the following
1751
+ field type identifiers: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE,
1752
+ SECOND, DATE, TIME.
1753
+
1754
+ EXTRACT returns the value of the corresponding field or part of the
1755
+ datetime.
1756
+
1757
+ ----
1758
+ extract_datetime_field :=
1759
+ EXTRACT(datetime_field FROM datetime_expression)
1760
+
1761
+ datetime_field := identification_variable
1762
+ ----
1763
+
1764
+ For the following field type identifiers, EXTRACT returns an integer
1765
+ value:
1766
+
1767
+ - YEAR means the calendar year.
1768
+ - QUARTER means the calendar quarter, numbered from 1 to 4.
1769
+ - WEEK means the ISO-8601 week number.
1770
+ - DAY means the calendar day of the month, numbered from 1.
1771
+ - HOUR means the hour of the day in 24-hour time, numbered from 0 to 23.
1772
+ - MINUTE means the minute of the hour, numbered from 0 to 59.
1773
+ - SECOND means the second of the minute, numbered from 0 to 59.
1774
+
1775
+ It is illegal to pass a datetime argument which does not have the given
1776
+ field type to EXTRACT.
1777
+
1778
+ ----
1779
+ extract_datetime_part :=
1780
+ EXTRACT(datetime_part FROM datetime_expression)
1781
+
1782
+ datetime_part := identification_variable
1783
+ ----
1784
+
1785
+ For the following field type identifiers, EXTRACT returns a part of the
1786
+ datetime value:
1787
+
1788
+ - DATE means the date part of a datetime.
1789
+ - TIME means the time part of a datetime.
1790
+
1791
+ It is illegal to pass a datetime argument which does not have the given
1792
+ part to EXTRACT.
1793
+
1794
+ [source,sql]
1795
+ ----
1796
+ FROM Course c WHERE c.year = EXTRACT(YEAR FROM CURRENT_DATE)
1797
+ ----
1746
1798
1747
1799
===== Invocation of Predefined and User-defined Database Functions [[a5311]]
1748
1800
@@ -3001,11 +3053,13 @@ functions_returning_numerics ::=
3001
3053
SQRT(arithmetic_expression) |
3002
3054
MOD(arithmetic_expression, arithmetic_expression) |
3003
3055
SIZE(collection_valued_path_expression) |
3004
- INDEX(identification_variable)
3056
+ INDEX(identification_variable) |
3057
+ extract_datetime_field
3005
3058
functions_returning_datetime ::=
3006
3059
CURRENT_DATE |
3007
3060
CURRENT_TIME |
3008
- CURRENT_TIMESTAMP
3061
+ CURRENT_TIMESTAMP |
3062
+ extract_datetime_part
3009
3063
functions_returning_strings ::=
3010
3064
CONCAT(string_expression, string_expression{, string_expression}*) |
3011
3065
SUBSTRING(string_expression, arithmetic_expression[, arithmetic_expression]) |
@@ -3014,6 +3068,12 @@ functions_returning_strings ::=
3014
3068
UPPER(string_expression)
3015
3069
trim_specification ::= LEADING | TRAILING | BOTH
3016
3070
function_invocation ::= FUNCTION(function_name{, function_arg}*)
3071
+ extract_datetime_field :=
3072
+ EXTRACT(datetime_field FROM datetime_expression)
3073
+ datetime_field := identification_variable
3074
+ extract_datetime_part :=
3075
+ EXTRACT(datetime_part FROM datetime_expression)
3076
+ datetime_part := identification_variable
3017
3077
function_arg ::=
3018
3078
literal |
3019
3079
state_valued_path_expression |
0 commit comments