From 3260a586edfdaaaea6f8c1c0710e8b2ec38bf569 Mon Sep 17 00:00:00 2001 From: "liu.yu" Date: Tue, 20 Mar 2018 14:26:18 +0800 Subject: [PATCH 1/2] $ Add an Overview of *Datetime Functions* in *Trafodion SQL Reference Manual --- .../sql_functions_and_expressions.adoc | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc b/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc index 83f8313600..63d25607fc 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc @@ -150,67 +150,109 @@ See the individual entry for the function. == Datetime Functions These functions use either a datetime value expression as an argument or -return a result of datetime data type: +return a result of DATETIME, VALUE or CHAR: -[cols="25%,75%"] +[caption="Table 7-3 "] +.Overview of DATETIME Functions +[cols="25%,50%,25%"] |=== +| *Name* | *Description* | *Return Data Type* | <> | Adds the integer number of months specified by _intr_expr_ to _datetime_expr_ and normalizes the result. +| DATE | <> | Converts a Julian timestamp to a TIMESTAMP value. +| TIMESTAMP | <> | Returns the current timestamp. You can also use the <>. +| TIMESTAMP | <> | Returns the current date. +| DATE | <> | Returns the current time. +| TIME | <> | Returns the current timestamp. You can also use the <>. +| TIMESTAMP | <> | Adds the interval specified by _interval_expression_ to _datetime_expr_. +| DATE | <> | Extracts the datetime field specified by _text_ from the interval value specified by interval and returns the result as an exact numeric value. +| NUMERIC VALUE | <> | Extracts the datetime field specified by _text_ from the datetime value specified by timestamp and returns the result as an exact numeric value. +| NUMERIC VALUE | <> | Subtracts the specified _interval_expression_ from _datetime_expr._ +| DATE or TIMESTAMP | <> | Returns the date with the time portion of the day truncated. +| TIMESTAMP | <> | Adds the interval specified by _datepart_ and _num_expr_ to _datetime_expr_. +| DATE or TIMESTAMP | <> | Returns the integer value for the number of _datepart_ units of time between _startdate_ and _enddate_. +| INTEGER VALUE | <> | Formats a datetime value for display purposes. +| CHAR | <> | Returns an integer value in the range 1 through 31 that represents the corresponding day of the month. You can also use DAYOFMONTH. +| INTEGER VALUE (from 1 to 31) | <> | Returns the name of the day of the week from a date or timestamp expression. +| CHAR | <> | Returns an integer value in the range 1 through 31 that represents the corresponding day of the month. You can also use DAY. +| INTEGER VALUE (from 1 to 31) | <> | Returns an integer value in the range 1 through 7 that represents the corresponding day of the week. +| INTEGER VALUE (from 1 to 7) | <> | Returns an integer value in the range 1 through 366 that represents the corresponding day of the year. +| INTEGER VALUE (from 1 to 366) | <> | Returns a specified datetime field from a datetime value expression or an interval value expression. +| NUMERIC VALUE | <> | Returns an integer value in the range 0 through 23 that represents the corresponding hour of the day. +| INTEGER VALUE (from 0 to 23) | <> | Converts a datetime value to a Julian timestamp. +| TIMESTAMP | <> | Returns an integer value in the range 0 through 59 that represents the corresponding minute of the hour. +| INTEGER VALUE (from 0 to 59) | <> | Returns an integer value in the range 1 through 12 that represents the corresponding month of the year. +| INTEGER VALUE (from 1 to 12) | <> | Returns a character literal that is the name of the month of the year (January, February, and so on). +| CHAR | <> | Returns an integer value in the range 1 through 4 that represents the corresponding quarter of the year. +| INTEGER VALUE (from 1 to 4) | <> | Returns an integer value in the range 0 through 59 that represents the corresponding second of the minute. +| INTEGER VALUE (from 0 to 59) +| <> | Retrieves the current date of the server rather than the session. +| DATE +| <> | Retrieves the current date and time (including fractional seconds with six-digit precision) of the server rather than the session. +| TIMESTAMP | <> | Adds the interval of time specified by _interval-ind_ and _num_expr_ to _datetime_expr_. +| DATE or TIMESTAMP | <> | Returns the integer value for the number of _interval-ind_units of time between _startdate_ and _enddate_. +| INTEGER VALUE | <> | Converts a datetime value to a character value. +| CHAR | <> | Converts a character value to a date or timestamp value. +| DATE or TIMESTAMP | <> | Converts a character value to a time value. +| TIME | <> | Converts a character value to a timestamp value. +| TIMESTAMP | <> | Returns an integer value in the range 1 through 54 that represents the corresponding week of the year. +| INTEGER VALUE (from 1 to 54) | <> | Returns an integer value that represents the year. +| INTEGER VALUE |=== See the individual entry for the function. @@ -2883,7 +2925,7 @@ The DAYNAME function returns the name of the day in ISO88591. Return the name of the day of the week from the start date column in the project table: -+ + ``` SELECT start_date, ship_timestamp, DAYNAME(start_date) FROM persnl.project From dabbfe6d7263a1281245cc6b6779769c4a42839a Mon Sep 17 00:00:00 2001 From: "liu.yu" Date: Thu, 22 Mar 2018 14:37:54 +0800 Subject: [PATCH 2/2] Incorporate Comments 1 --- .../sql_functions_and_expressions.adoc | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc b/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc index 63d25607fc..b86f4c8afd 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc @@ -150,7 +150,7 @@ See the individual entry for the function. == Datetime Functions These functions use either a datetime value expression as an argument or -return a result of DATETIME, VALUE or CHAR: +return a result of datetime data type: [caption="Table 7-3 "] .Overview of DATETIME Functions @@ -175,11 +175,11 @@ to _datetime_expr_ and normalizes the result. to _datetime_expr_. | DATE | <> | Extracts the datetime field specified by _text_ from the interval value -specified by interval and returns the result as an exact numeric value. -| NUMERIC VALUE +specified by interval and returns the result as an exact numeric. +| NUMERIC | <> | Extracts the datetime field specified by _text_ from the datetime value -specified by timestamp and returns the result as an exact numeric value. -| NUMERIC VALUE +specified by timestamp and returns the result as an exact numeric. +| NUMERIC | <> | Subtracts the specified _interval_expression_ from _datetime_expr._ | DATE or TIMESTAMP @@ -188,49 +188,49 @@ _datetime_expr._ | <> | Adds the interval specified by _datepart_ and _num_expr_ to _datetime_expr_. | DATE or TIMESTAMP -| <> | Returns the integer value for the number of _datepart_ units of time +| <> | Returns the integer for the number of _datepart_ units of time between _startdate_ and _enddate_. -| INTEGER VALUE +| INTEGER | <> | Formats a datetime value for display purposes. | CHAR -| <> | Returns an integer value in the range 1 through 31 that represents the +| <> | Returns an integer in the range 1 through 31 that represents the corresponding day of the month. You can also use DAYOFMONTH. -| INTEGER VALUE (from 1 to 31) +| INTEGER (from 1 to 31) | <> | Returns the name of the day of the week from a date or timestamp expression. | CHAR -| <> | Returns an integer value in the range 1 through 31 that represents the +| <> | Returns an integer in the range 1 through 31 that represents the corresponding day of the month. You can also use DAY. -| INTEGER VALUE (from 1 to 31) -| <> | Returns an integer value in the range 1 through 7 that represents the +| INTEGER (from 1 to 31) +| <> | Returns an integer in the range 1 through 7 that represents the corresponding day of the week. -| INTEGER VALUE (from 1 to 7) -| <> | Returns an integer value in the range 1 through 366 that represents the +| INTEGER (from 1 to 7) +| <> | Returns an integer in the range 1 through 366 that represents the corresponding day of the year. -| INTEGER VALUE (from 1 to 366) +| INTEGER (from 1 to 366) | <> | Returns a specified datetime field from a datetime value expression or an interval value expression. -| NUMERIC VALUE -| <> | Returns an integer value in the range 0 through 23 that represents the +| NUMERIC +| <> | Returns an integer in the range 0 through 23 that represents the corresponding hour of the day. -| INTEGER VALUE (from 0 to 23) +| INTEGER (from 0 to 23) | <> | Converts a datetime value to a Julian timestamp. | TIMESTAMP -| <> | Returns an integer value in the range 0 through 59 that represents the +| <> | Returns an integer in the range 0 through 59 that represents the corresponding minute of the hour. -| INTEGER VALUE (from 0 to 59) -| <> | Returns an integer value in the range 1 through 12 that represents the +| INTEGER (from 0 to 59) +| <> | Returns an integer in the range 1 through 12 that represents the corresponding month of the year. -| INTEGER VALUE (from 1 to 12) +| INTEGER (from 1 to 12) | <> | Returns a character literal that is the name of the month of the year (January, February, and so on). | CHAR -| <> | Returns an integer value in the range 1 through 4 that represents the +| <> | Returns an integer in the range 1 through 4 that represents the corresponding quarter of the year. -| INTEGER VALUE (from 1 to 4) -| <> | Returns an integer value in the range 0 through 59 that represents the +| INTEGER (from 1 to 4) +| <> | Returns an integer in the range 0 through 59 that represents the corresponding second of the minute. -| INTEGER VALUE (from 0 to 59) +| INTEGER (from 0 to 59) | <> | Retrieves the current date of the server rather than the session. | DATE | <> | Retrieves the current date and time (including fractional seconds with six-digit precision) of the server rather than the session. @@ -238,8 +238,8 @@ corresponding second of the minute. | <> | Adds the interval of time specified by _interval-ind_ and _num_expr_ to _datetime_expr_. | DATE or TIMESTAMP -| <> | Returns the integer value for the number of _interval-ind_units of time between _startdate_ and _enddate_. -| INTEGER VALUE +| <> | Returns the integer for the number of _interval-ind_units of time between _startdate_ and _enddate_. +| INTEGER | <> | Converts a datetime value to a character value. | CHAR | <> | Converts a character value to a date or timestamp value. @@ -248,11 +248,11 @@ _num_expr_ to _datetime_expr_. | TIME | <> | Converts a character value to a timestamp value. | TIMESTAMP -| <> | Returns an integer value in the range 1 through 54 that represents the +| <> | Returns an integer in the range 1 through 54 that represents the corresponding week of the year. -| INTEGER VALUE (from 1 to 54) -| <> | Returns an integer value that represents the year. -| INTEGER VALUE +| INTEGER (from 1 to 54) +| <> | Returns an integer that represents the year. +| INTEGER |=== See the individual entry for the function. @@ -2397,7 +2397,7 @@ DATEADD(DAY, 7, timestamp'2008-02-29 00:00:00') [[datediff_function]] == DATEDIFF Function -The DATEDIFF function returns the integer value for the number of +The DATEDIFF function returns the integer for the number of _datepart_ units of time between _startdate_ and _enddate_. DATEDIFF is a {project-name} SQL extension. @@ -2941,7 +2941,7 @@ Start/Date Time/Shipped (EXPR) == DAYOFMONTH Function The DAYOFMONTH function converts a DATE or TIMESTAMP expression into an -INTEGER value in the range 1 through 31 that represents the +INTEGER in the range 1 through 31 that represents the corresponding day of the month. The result returned by the DAYOFMONTH function is equal to the result returned by the DAY function. @@ -2977,7 +2977,7 @@ Start/Date Time/Shipped (EXPR) == DAYOFWEEK Function The DAYOFWEEK function converts a DATE or TIMESTAMP expression into an -INTEGER value in the range 1 through 7 that represents the corresponding +INTEGER in the range 1 through 7 that represents the corresponding day of the week. The value 1 represents Sunday, 2 represents Monday, and so forth. @@ -3015,7 +3015,7 @@ The value returned is 5, representing Thursday. The week begins on Sunday. == DAYOFYEAR Function The DAYOFYEAR function converts a DATE or TIMESTAMP expression into an -INTEGER value in the range 1 through 366 that represents the +INTEGER in the range 1 through 366 that represents the corresponding day of the year. DAYOFYEAR is a {project-name} SQL extension. @@ -3996,7 +3996,7 @@ tom 91 77 43 == HOUR Function The HOUR function converts a TIME or TIMESTAMP expression into an -INTEGER value in the range 0 through 23 that represents the +INTEGER in the range 0 through 23 that represents the corresponding hour of the day. HOUR is a {project-name} SQL extension. @@ -4917,7 +4917,7 @@ SELECT MIN (salary) FROM persnl.employee; == MINUTE Function The MINUTE function converts a TIME or TIMESTAMP expression into an -INTEGER value, in the range 0 through 59, that represents the +INTEGER, in the range 0 through 59, that represents the corresponding minute of the hour. MINUTE is a {project-name} SQL extension. @@ -8412,7 +8412,7 @@ TIMESTAMPADD (SQL_TSI_SECOND, -5, DATE '2008-07-01') [[timestampdiff_function]] == TIMESTAMPDIFF Function -The TIMESTAMPDIFF function returns the integer value for the number of +The TIMESTAMPDIFF function returns the integer for the number of _interval-ind_ units of time between _startdate_ and _enddate_. If _enddate_ precedes _startdate_, the return value is negative or zero. @@ -9278,7 +9278,7 @@ Start/Date Time/Shipped (EXPR) == YEAR Function The YEAR function converts a DATE or TIMESTAMP expression into an -INTEGER value that represents the year. +INTEGER that represents the year. YEAR is a {project-name} SQL extension.