Re: storing repeating dates / events - Mailing list pgsql-general

From Taras Kopets
Subject Re: storing repeating dates / events
Date
Msg-id 48C322AC.9040605@gmail.com
Whole thread Raw
In response to storing repeating dates / events  ("rkmr.em@gmail.com" <rkmr.em@gmail.com>)
List pgsql-general
rkmr.em@gmail.com 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: 64-bit Compile Failure on Solaris 10 with OpenSSL
Next
From: "Randal T. Rioux"
Date:
Subject: Re: 64-bit Compile Failure on Solaris 10 with OpenSSL