From: Ross J. Reedstrom <reedstrm@rice.edu>
To: sandis <sandis@mediaparks.lv>
Cc: pgsql-sql@postgresql.org
Subject: Re: date comparision ???
Date: Wed, 12 Jul 2000 11:55:56 -0500
Message-ID: <20000712115556.D1487@rice.edu> (raw)
In-Reply-To: <00c301bfea4c$265ff460$d17b02c3@mediaparks.lv>
References: <005a01bfe83e$4fc52600$d17b02c3@mediaparks.lv>
<39663B6D.57B67664@ipinc.com>
<00c301bfea4c$265ff460$d17b02c3@mediaparks.lv>
On Mon, Jul 10, 2000 at 11:52:16AM +0300, sandis wrote:
> Thanks for your input. Unfortunately, it doesn't helped..
>
> Here is the samples.
>
> This query works fine:
> SELECT datums_ FROM jaunumi WHERE flag = 'a' AND date_part('year',datetime
> '2000-06-02 06:11:01-07') = '2000' LIMIT 1;
> datums_
> ----------------------
> 2000-07-06 18:51:27+03
> (1 row)
>
> But this fails, obviously because the function doesnt know the value of
> datums_:
> SELECT datums_ FROM jaunumi WHERE flag = 'a' AND date_part('year',datetime
> 'datums_') = '2000' LIMIT 1;
> ERROR: Bad datetime external representation 'datums_'
>
> datums_ is a timestamp field. How do i get it's value to use in date_part()
> function??
> date_part('year',datums_) and date_part('year',datetime datums_) doesnt
> work also!
Right, that's the syntax for a datetime literal, not a cast. How about:
SELECT datums_ FROM jaunumi WHERE flag = 'a' AND
date_part('year', datetime(datums_)) = 2000 LIMIT 1;
By the way, what version are you using? The functional cast is needed for
6.5.X, but not for 7.X.
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: reedstrm@rice.edu, sandis@mediaparks.lv
Subject: Re: date comparision ???
In-Reply-To: <20000712115556.D1487@rice.edu>
References: <005a01bfe83e$4fc52600$d17b02c3@mediaparks.lv> <39663B6D.57B67664@ipinc.com> <00c301bfea4c$265ff460$d17b02c3@mediaparks.lv> <20000712115556.D1487@rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox