Re: order of adding date & interval values?
От | Darren Ferguson |
---|---|
Тема | Re: order of adding date & interval values? |
Дата | |
Msg-id | Pine.LNX.4.10.10205022114520.13370-100000@thread.crystalballinc.com обсуждение исходный текст |
Ответ на | order of adding date & interval values? (Lev Lvovsky <lists1@sonous.com>) |
Список | pgsql-general |
Postgresql expects a date first from what i am seeing. You can't just have 40 years then add a date because what is the 40 years. You are adding a specific date to 40 years which the parser says is not correct and logically this is true. You should always have the date first before you add any interval of time to it. The difference between date('2001-01-01') and date '2001-01-01' is this date('2001-01-01') Postgres is thinking this is a function defined in the database. So you will get the error message. This is my 2 cents HTH Darren Ferguson On Thu, 2 May 2002, Lev Lvovsky wrote: > hello, > > using 7.2.1 > > is there any reason why the order of operations of the following query > would matter? > > here's an example: > > diw=# select interval '40 years' + date '2001-01-01' as test; > test > --------------------- > 2001-01-01 00:00:00 > (1 row) > > diw=# select date '2001-01-01' + interval '40 years' as test; > test > --------------------- > 2041-01-01 00:00:00 > (1 row) > > note how the first query doesn't return the proper response. > > > also, is there a difference between: > "interval('40 years') " and "interval '40 years' " ? > > or > > "date('2001-01-01')" and "date '2001-01-01' " ? > > because only the query at the top of this message works, the following > doesn't: > > diw=# select date('2001-01-01') + interval('40 years') as test; > ERROR: parser: parse error at or near "'" > > I realize that answers my question, but why? > > any help would be appreciated!!! > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >
В списке pgsql-general по дате отправления: