mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
SQL: Fix issue with mins & hours for DATEDIFF (#49252)
Previously, DATEDIFF for minutes and hours was doing a rounding calculation using all the time fields (secs, msecs/micros/nanos). Instead it should first truncate the 2 dates to the respective field (mins or hours) zeroing out all the more detailed time fields and then make the subtraction.
This commit is contained in:
parent
f27511c9d1
commit
124cd18e20
5 changed files with 93 additions and 7 deletions
|
@ -395,6 +395,20 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[dateDiffDateTimeSeconds]
|
|||
include-tagged::{sql-specs}/docs/docs.csv-spec[dateDiffDateQuarters]
|
||||
--------------------------------------------------
|
||||
|
||||
[NOTE]
|
||||
For `hour` and `minute`, `DATEDIFF` doesn't do any rounding, but instead first truncates
|
||||
the more detailed time fields on the 2 dates to zero and then calculates the subtraction.
|
||||
|
||||
[source, sql]
|
||||
--------------------------------------------------
|
||||
include-tagged::{sql-specs}/docs/docs.csv-spec[dateDiffDateTimeHours]
|
||||
--------------------------------------------------
|
||||
|
||||
[source, sql]
|
||||
--------------------------------------------------
|
||||
include-tagged::{sql-specs}/docs/docs.csv-spec[dateDiffDateTimeMinutes]
|
||||
--------------------------------------------------
|
||||
|
||||
[source, sql]
|
||||
--------------------------------------------------
|
||||
include-tagged::{sql-specs}/docs/docs.csv-spec[dateDiffDateMinutes]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue