Skip site navigation (1) Skip section navigation (2)

date comparison

From: "sandis" <sandisj(at)parks(dot)lv>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: date comparison
Date: 2000-07-07 18:03:27
Message-ID: 003801bfe83d$b8521760$d17b02c3@mediaparks.lv (view raw or flat)
Thread:
Lists: pgsql-novice
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!


Responses

pgsql-novice by date

Next:From: James HallDate: 2000-07-07 18:07:08
Subject: User attributes
Previous:From: ERIC Lawson - x52010Date: 2000-07-07 17:19:10
Subject: Re: order by accents?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group