Solved

Oracle SQL

Posted on 2013-02-04
3
259 Views
Last Modified: 2013-02-04
I need to pull all of the birthdate records in a table which have a month of January and a day of 1 no matter what year.    When I use the where clause as AND (voters.date_of_birth like To_date ('01/01','MM/DD')) it only pulls records for 1913.  Can anyone help with this?
0
Comment
Question by:restockett
3 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 38852199
If you have an index on date_of_birth this will ignore it but:
where to_char(voters.date_of_birth,'MMDD') = '0101';
0
 
LVL 34

Expert Comment

by:johnsone
ID: 38852381
Since you are looking for 1/1, you can use trunc

where date_of_birth = trunc(date_of_birth, 'yyyy')

Of course, that only works with 1/1.
0
 
LVL 31

Expert Comment

by:awking00
ID: 38852643
where mod(months_between(trunc(sysdate,'yyyy'),date_of_birth),12) = 0
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now