Search Postgresql Archives

Re: Date math

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Sun, Jun 28, 2009 at 2:52 PM, Joe Conway <mail@xxxxxxxxxxxxx> wrote:
Adam Rich wrote:
Hello,
I have a table with a DATE field "birth_date".  The data obviously contains various dates in the past, such as 07/04/1970.  In my query, I need to retrieve the person's "next" birthday.  In other words, for the example date 07/04/1970, the query should return 07/04/2009 for the current week, but after this July 4th, it would return 07/04/2010. Ultimately, I need to find people with "next" birthdays within a certain range.


If all you want to do is check to see if someone's birthday is coming up within a set period, then this query will return true or false:


SELECT extract(doy FROM TIMESTAMP '1970-07-20')
BETWEEN
extract(doy FROM now()) AND
extract( doy FROM CURRENT_DATE +30)

Guy Flaherty

[]
[]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux