Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date difference returns month_interval instead of day_interval #3917

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Date difference returns month_interval instead of day_interval #3917

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working normal SQL

Comments

@monetdb-team
Copy link

Date: 2016-02-04 15:36:08 +0100
From: @swingbit
To: SQL devs <>
Version: 11.19.9 (Oct2014-SP2)
CC: @njnes

Last updated: 2016-03-25 09:59:19 +0100

Comment 21768

Date: 2016-02-04 15:36:08 +0100
From: @swingbit

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Build Identifier:

Casting the result of a date difference to double:

sql>select cast ( cast('2016-01-01' as date) - cast('2015-01-01' as date) as double);
types month_interval(32,0) and double(53,0) are not equal

  1. https://www.monetdb.org/Documentation/SQLreference/Temporal mentions:
    "For difference calculations between dates (in numbers of days) we use signed integer."
    However it seems that month_interval is used.

  2. No matter if you use month or day interval, why is a cast to double not possible? First casting to integer and then to double does work (see below). Is upcasting not working transitively?

sql>select cast ( cast ( cast('2016-01-01' as date) - cast('2015-01-01' as date) as int) as double);
+--------------------------+
| L4 |
+==========================+
| 365 |
+--------------------------+

Reproducible: Always

$ mserver5 --version
MonetDB 5 server v11.21.14 (64-bit, 64-bit oids, 128-bit integers)
This is an unreleased version
Copyright (c) 1993-July 2008 CWI
Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
Visit http://www.monetdb.org/ for further information
Found 15.6GiB available memory, 8 available cpu cores
Libraries:
libpcre: 8.37 2015-04-28 (compiled with 8.37)
openssl: OpenSSL 1.0.1k 8 Jan 2015 (compiled with OpenSSL 1.0.1k-fips 8 Jan 2015)
libxml2: 2.9.3 (compiled with 2.9.3)
Compiled by: roberto@photon.hq.spinque.com (x86_64-unknown-linux-gnu)
Compilation: gcc -O3 -pipe -Werror -Wall -Wextra -W -Werror-implicit-function-declaration -Wpointer-arith -Wdeclaration-after-statement -Wundef -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wpacked -Wunknown-pragmas -Wvariadic-macros -fstack-protector-all -Wstack-protector -Wpacked-bitfield-compat -Wsync-nand -Wjump-misses-init -Wmissing-include-dirs -Wlogical-op -Wunreachable-code -D_FORTIFY_SOURCE=2
Linking : /usr/bin/ld -m elf_x86_64

Comment 21889

Date: 2016-03-13 20:10:59 +0100
From: @njnes

was fixed in the 2015 branch

Comment 21960

Date: 2016-03-25 09:59:19 +0100
From: @sjoerdmullender

Jul2015-SP3 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working normal SQL
Projects
None yet
Development

No branches or pull requests

2 participants