From: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu> |
---|---|
To: | sandis <sandis(at)mediaparks(dot)lv> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: date comparision ??? |
Date: | 2000-07-12 16:55:56 |
Message-ID: | 20000712115556.D1487@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-07-12 17:06:36 | Re: Opposite of LOCK |
Previous Message | Brian Powell | 2000-07-12 16:24:36 | Bug in to_char() |