From: | Guy Flaherty <naoshika(at)gmail(dot)com> |
---|---|
To: | Adam Rich <adam(dot)r(at)sbcglobal(dot)net> |
Cc: | postgres general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Date math |
Date: | 2009-06-28 06:21:25 |
Message-ID: | 23d251df0906272321q4f9bd335i81839c51f42c4868@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Jun 28, 2009 at 2:52 PM, Joe Conway <mail(at)joeconway(dot)com> 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
[]
[]
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan Sergio Borgonovo | 2009-06-28 10:05:08 | Replication and coding good practices |
Previous Message | Greg Smith | 2009-06-28 05:59:56 | Re: horizontal sharding |