• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Oracle SQL

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
restockett
Asked:
restockett
1 Solution
 
slightwv (䄆 Netminder) Commented:
If you have an index on date_of_birth this will ignore it but:
where to_char(voters.date_of_birth,'MMDD') = '0101';
0
 
johnsoneSenior Oracle DBACommented:
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
 
awking00Commented:
where mod(months_between(trunc(sysdate,'yyyy'),date_of_birth),12) = 0
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now