INTERVALs - Mailing list pgsql-hackers
From | Jose' Soares Da Silva |
---|---|
Subject | INTERVALs |
Date | |
Msg-id | Pine.LNX.3.96.980414101151.433A-100000@proxy.bazzanese.com Whole thread Raw |
List | pgsql-hackers |
============================================================================ POSTGRESQL BUG REPORT TEMPLATE ============================================================================ Your name : Jose' Soares Da Silva Your email address : sferac@bo.nettuno.it System Configuration --------------------- Architecture (example: Intel Pentium) : Intel Pentium Operating System (example: Linux 2.0.26 ELF) : Linux 2.0.31 Elf PostgreSQL version (example: PostgreSQL-6.1) : PostgreSQL-snapshot april 6, 1998 Compiler used (example: gcc 2.7.2) : gcc 2.7.2.1 Please enter a FULL description of your problem: ------------------------------------------------ There are some bugs on INTERVALs... ...the keywords YEAR,MONTH,DAY,HOUR, MINUTE and SECOND must be specified outside quotes not inside. /* INTERVAL year-month: written as the keyword INTERVAL, followed by a (year-month) interval string consisting of an opening single quote, an optional sign, either or both yyyy and mm (with a hyphen separator if both are specified), and closing single quote, followed by YEAR, MONTH or YEAR TO MONTH (as applicable). examples: INTERVAL '-1' YEAR; INTERVAL '2-6' YEAR TO MONTH; */ postgres=> SELECT INTERVAL '2-6' YEAR TO MONTH; <-- year to month outside '' ?? ERROR: parser: parse error at or near "year" postgres=> SELECT INTERVAL '2-6 YEAR TO MONTH'; ERROR: Bad timespan external representation '2-6 YEAR TO MONTH' /* INTERVAL day-time: written as the keyword INTERVAL, followed by a (day-time) interval string consisting of an opening single quote, an optional sign, a contiguous nonempty subsequence of dd, hh, mm and ss[.[nnnnnn]] (with a space separator between dd and the rest, if dd is specified, and colon separators elsewhere), and a closing single quote, followed by the appropriate "start [TO end]" specification. examples: INTERVAL '2 12' DAY TO HOUR; INTERVAL '-4.50' SECOND; */ postgres=> SELECT INTERVAL '2 12 DAY TO HOUR' AS two_days_12_hrs; two_days_12_hrs --------------- @ 14 days <--- this should be 2 days and 12 hours !! (1 row) postgres=> SELECT INTERVAL '-4.50 SECOND' AS four_sec_half_ago; ERROR: Bad timespan external representation '-4.50 SECOND' ^^^^ decimal point ?? postgres=> SELECT INTERVAL '-4 SECOND' AS four_sec_half_ago; four_sec_half_ag ^^^ without decimal point it's ok. ----------------- @ 4 secs ago (1 row) --arithmetic: postgres=> SELECT INTERVAL '3 hour' / INTERVAL '1 hour'; ?column? -------- @ 3 secs <---- why 3 secs ? It should be 3 hour !! (1 row) postgres=> SELECT INTERVAL '4 hour' * INTERVAL '3 hour'; ERROR: There is no operator '*' for types 'timespan' and 'timespan' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT INTERVAL '4 hour' * 3; ERROR: There is no operator '*' for types 'timespan' and 'int4' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT INTERVAL '4 hour' / 2; ERROR: There is no operator '/' for types 'timespan' and 'int4' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT DATE '1998-07-31' + INTERVAL '1 MONTH'; ERROR: There is no operator '+' for types 'date' and 'timespan' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT CURRENT_TIME + INTERVAL '1 HOUR'; ERROR: There is no operator '+' for types 'time' and 'timespan' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT CURRENT_TIMESTAMP + INTERVAL '1 DAY'; ERROR: There is no operator '+' for types 'timestamp' and 'timespan' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR postgres=> SELECT CURRENT_TIME - TIME '12:34'; ERROR: There is no operator '-' for types 'time' and 'time' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR CREATE TABLE inter ( inter1 INTERVAL YEAR, inter2 INTERVAL YEAR TO MONTH, inter3 INTERVAL MONTH, inter4 INTERVAL DAY, inter5 INTERVAL HOUR TO MINUTE, inter6 INTERVAL MINUTE TO SECOND, <---error on this one. ERROR: parser: parse error at or near "to" inter7 INTERVAL DAY (3) TO SECOND (3) <---error on this one. ); ERROR: parser: parse error at or near "(" If you know how this problem might be fixed, list the solution below: --------------------------------------------------------------------- ??
pgsql-hackers by date: