Re: storing repeating dates / events
От | Taras Kopets |
---|---|
Тема | Re: storing repeating dates / events |
Дата | |
Msg-id | 48C322AC.9040605@gmail.com обсуждение исходный текст |
Ответ на | storing repeating dates / events ("rkmr.em@gmail.com" <rkmr.em@gmail.com>) |
Список | 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 по дате отправления: