[EMAIL PROTECTED] wrote:
Hi
I want to store dates / events for example birthdays (or may 5th) that repeats every year..
what is the best way to do in postgres?
if i use timestamp it is going to be use the current year.. how do i do this?
Any anniversary today?

SELECT *
FROM your_table_with_timestamp_column
WHERE EXTRACT(DAY FROM your_column) = EXTRACT(DAY FROM now())
 AND EXTRACT(MONTH FROM your_column) = EXTRACT(MONTH FROM now())
AND your_column <= now(); -- prevent to show events that will be in the future

Or May 5th:
SELECT *
FROM your_table_with_timestamp_column
WHERE EXTRACT(DAY FROM your_column) = EXTRACT(DAY FROM TIMESTAMP '2008-05-05') AND EXTRACT(MONTH FROM your_column) = EXTRACT(MONTH FROM TIMESTAMP '2008-05-05') AND '2008-05-05'::timestamp <= now(); -- prevent to show events that will be in the future

Sorry, if I misunderstood your question.

Taras Kopets

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to