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

Calculation Date function using interval and year #3215

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

Calculation Date function using interval and year #3215

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

Comments

@monetdb-team
Copy link

Date: 2013-01-03 19:00:31 +0100
From: Glauber <>
To: SQL devs <>
Version: 11.13.9 (Oct2012-SP3)

Last updated: 2013-02-19 13:18:00 +0100

Comment 18316

Date: 2013-01-03 19:00:31 +0100
From: Glauber <>

User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
Build Identifier:

I need to get the same date period for the previous year based on the current year. Example: 01.01.2013 to 02.01.2013 - last year Period: 2012-01-01 to 2012-01-02, then used the same sql I use in Postgres.

select date from dim_tempo
where date between cast ('2013-01-01 'as timestamp) + INTERVAL' -1 'year
and cast ('2013-01-02 'as timestamp) + INTERVAL' -1 'year

  • -------------------- +
    | Date |
  • ==================== +
    | 2012-01-01 00:00:00 |
    | 2012-01-02 00:00:00 |
  • -------------------- +

MonetDB - Result Wrong

select date from dim_tempo
where date between cast ('2013-01-01 'as date) + interval' -1 'year
and cast ('2013-01-02 'as date) + interval' -1 'year;

  • ------------ +
    | Date |
  • ============ +
    | 2012-01-02 |
    | 2012-01-03 |
  • ------------ +

Reproducible: Always

Steps to Reproduce:

DDL and inserts Postgres:
CREATE TABLE dim_tempo
(
id_tempo double precision,
data timestamp without time zone
);

insert into dim_tempo values (1,'2012-01-01'), (2,'2012-01-02'), (3,'2012-01-03'), (4,'2012-01-04'), (5,'2013-01-01'), (6,'2013-01-02'), (7,'2013-01-03'), (8,'2013-01-04');

DDL and inserts MonetDB:
CREATE TABLE dim_tempo
(
id_tempo integer,
data date
);

insert into dim_tempo values (1,'2012-01-01'), (2,'2012-01-02'), (3,'2012-01-03'), (4,'2012-01-04'), (5,'2013-01-01'), (6,'2013-01-02'), (7,'2013-01-03'), (8,'2013-01-04');

  1. run this query on another DBMS example: postgres

select date from dim_tempo
where date between cast ('2013-01-01 'as timestamp) + INTERVAL' -1 'year
and cast ('2013-01-02 'as timestamp) + INTERVAL' -1 'year

  1. run this query in Monetdb, I used to run mclient
    select date from dim_tempo
    where date between cast ('2013-01-01 'as date) + interval' -1 'year
    and cast ('2013-01-02 'as date) + interval' -1 'year;

Actual Results:

  • ------------ +
    | Date |
  • ============ +
    | 2012-01-02 |
    | 2012-01-03 |
  • ------------ +

Expected Results:

  • ------------ +
    | Date |
  • ============ +
    | 2012-01-01 |
    | 2012-01-02 |
  • ------------ +

I am Brazilian!

Comment 18442

Date: 2013-01-29 10:22:37 +0100
From: @sjoerdmullender

Changeset fdbfe3a3f1bd made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

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

Changeset description:

Add test for bug #3215.

Comment 18443

Date: 2013-01-29 10:37:31 +0100
From: @sjoerdmullender

Changeset 27f146dcaa6c made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

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

Changeset description:

Add or subtract number of days in correct month.
We need to adjust the year when wrapping months since some years are
leap years.
This fixes bug #3215.

Comment 18444

Date: 2013-01-29 10:40:31 +0100
From: @sjoerdmullender

Should appear in the next release.

Comment 18516

Date: 2013-02-19 13:18:00 +0100
From: @sjoerdmullender

Feb2013 has been released.

@monetdb-team monetdb-team added bug Something isn't working normal SQL labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Nov 9, 2022
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