Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Help - birthdays! 1

Status
Not open for further replies.

notadba

MIS
May 28, 2003
154
AU
Hi,

Having one of those days (and not enough familiarity with date manipulation in Oracle).

What I need is a query that will allow me to search for people who will have a birthday within a date range - for example between August 1 and August 15 (irrespective of year).

Table Columns:
ID, Name, birthdate, etc.

I know I should know how to do this...

Thanks in advance
 
Hi

I would say, the key is [tt]'ddd'[/tt] :
Code:
[blue]SQL>[/blue] [b]select[/b] * [b]from[/b] bd;

        ID NAME       BIRTH
---------- ---------- ---------
         1 one        01-JAN-00
         2 two        15-JUN-01
         3 three      30-JUL-02
         4 four       01-AUG-03
         5 five       15-AUG-05
         6 six        16-AUG-05
         7 seven      01-SEP-06

7 rows selected.

[blue]SQL>[/blue] [b]select[/b] * [b]from[/b] bd [b]where[/b] to_char(birth,[i]'ddd'[/i]) [b]between[/b] to_char(to_date([i]'08-01'[/i],[i]'mm-dd'[/i]),[i]'ddd'[/i]) [b]and[/b] to_char(to_date([i]'08-15'[/i],[i]'mm-dd'[/i]),[i]'ddd'[/i]);

        ID NAME       BIRTH
---------- ---------- ---------
         4 four       01-AUG-03
         5 five       15-AUG-05

Feherke.
 
Thank Feherke for your quick response,

Just took some tweaking through a query tool that always converts dates to char and then screws up any date calc functions etc.

Saved me!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top