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

EXTRACT(SECOND FROM timestamp) always returns 0 integer seconds part. #2793

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

EXTRACT(SECOND FROM timestamp) always returns 0 integer seconds part. #2793

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


Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2011-03-25 18:20:21 +0100
To: SQL devs <>
Version: 11.1.1 (Mar2011) [obsolete]
CC: @njnes

Last updated: 2011-04-28 16:25:34 +0200

Comment 15612

Date: 2011-03-25 18:20:21 +0100

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16
Build Identifier:

EXTRACT(SECOND FROM timestamp) appears to be incorrectly implemented. It always returns 0 for the integer part. I have traced this behaviour to the way this SQL functionality was implemented.

Reproducible: Always

Steps to Reproduce:

Here is a sample session:

Welcome to mclient, the MonetDB/SQL interactive terminal (Oct2010-SP1)
Database: MonetDB v5.22.3, 'demo'
Type \q to quit, ? for a list of available commands
auto commit mode: on

sql> select extract(second from timestamp '2011-3-10 9:30:42.246');

Actual Results:

| second_single_value |
| 0.246 |

Expected Results:

| second_single_value |
| 42.246 |

We can find the source of this behaviour using EXPLAIN :

sql> explain select extract(second from timestamp '2011-3-10 9:30:42.246');

function user.s2_1{autoCommit=true}():void;
_4 := mtime.milliseconds(2011-03-10 09:30:42.246:timestamp);
end s2_1;

mtime.milliseconds is declared (modules/atoms/mtime.mal) as follows
413 command milliseconds(d:daytime) :int
414 address MTIMEdaytime_extract_milliseconds

and MTIMEdaytime_extract_milliseconds only returns the millisecond part.

Comment 15675

Date: 2011-03-28 17:36:27 +0200
From: @sjoerdmullender

The Mar2011 version has been released.

Comment 15699

Date: 2011-03-30 11:58:25 +0200
From: @njnes

Changeset f1010cea0102 made by Niels Nes in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=f1010cea0102

Changeset description:

fixed bug #2793, ie implemented extract( seconds) including fractional milli

Comment 15700

Date: 2011-03-30 11:58:30 +0200
From: @njnes

fixed by implementing the required seconds with fractional milliseconds.
Test added extract_seconds.Bug-2793.sql

Comment 15746

Date: 2011-04-28 16:25:34 +0200
From: @sjoerdmullender

The Apr2011 release has been uploaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant