Solved

Oracle SQL

Posted on 2013-02-04
3
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

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 35

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 32

Expert Comment

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

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

691 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