date comparison
date comparison
От:
"sandis" <sandisj@parks.lv>
Дата:
Is anyone out here can give some advice?
i have a table with a timestamp field.
i should know if there is records for the particular year and month
so i need a query like (in MySQL it was very simple, but i should move to
postgres!):
SELECT something FROM mytable WHERE MONTH('timestamp_field')=07
AND YEAR('timestamp_field')=2000 LIMIT 1;
So, i am looking for date/time functions:
SELECT * FROM table WHERE date_part('year',timestamp 'timestamp_field') =
2000;
but it doesn't work...(ERROR: Bad abstime external representation
'timestamp_field')
may be i need subselect or abstime(timestamp) function??
I suppose it's a lame q, but i cannot solve it today...
Thanks!
Re: date comparison
От:
Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
Дата:
On Friday 7 July 2000, at 21 h 3, the keyboard of "sandis"
wrote:
> SELECT something FROM mytable WHERE MONTH('timestamp_field')=07
> AND YEAR('timestamp_field')=2000 LIMIT 1;
SELECT * FROM conferences WHERE date_part('year', date_begin) = 2000
AND date_part('month', date_begin) = 7;