Re: [GENERAL] select using date

From: Kevin Heflin <kheflin(at)shreve(dot)net>
To: sferac(at)bo(dot)nettuno(dot)it
Cc: "PGSQL-General (E-mail)" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] select using date
Date: 1999-01-08 14:52:38
Message-ID: Pine.LNX.4.02.9901080843280.30034-100000@mercury.shreve.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, 8 Jan 1999, Jose' Soares wrote:

> Try:
>
> select current_date, CURRENT_DATE - INTERVAL '1 DAY';
> ?column?|?column?
> ----------+----------------------
> 1999-01-08|1999-01-07 00:00:00+01
> (1 row)
>
> PostgreSQL has a syntax sligth different than SQL92. You have to enclose
> '1 DAY' instead of '1' DAY.

Well, I tried:

select current_date, CURRENT_DATE - INTERVAL '1 DAY';

but receive the following:

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

After trying somethings, I was able to get this to work:

select CURRENT_DATE -1;

will subtract 1 day from the current date... which gives me what I need
for now.

Thanks

Kevin

--------------------------------------------------------------------
Kevin Heflin | ShreveNet, Inc. | Ph:318.222.2638 x103
VP/Mac Tech | 333 Texas St #619 | FAX:318.221.6612
kheflin(at)shreve(dot)net | Shreveport, LA 71101 | http://www.shreve.net
--------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Hornburg 1999-01-08 15:46:54 Re: [GENERAL] Patch 6.4.1 to 6.4.2
Previous Message Walt Bigelow 1999-01-08 12:41:10 postgresql v6.4.2 c funcs and null text pointers...

Browse pgsql-hackers by date

  From Date Subject
Next Message Massimo Dal Zotto 1999-01-08 15:41:48 bug in libpgtcl listen
Previous Message Horak Daniel 1999-01-08 13:26:54 New patches for running PostgreSQL on Windows