Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:05:38+00:00 2026-06-07T18:05:38+00:00

I am trying to search a record that is structured like this trans_Date, customer_age,

  • 0

I am trying to search a record that is structured like this

trans_Date, customer_age, etc

Where customer age is the age at the time of the transaction. What I need to do is to select all customers who are currently a certain age, who had a transaction between a date range.

Lets say I only wanted current 20 year olds who purchased when between 2005 and 2010

I came up with this

select * from trans_logs 
where trans_date between TO_DATE("07/13/2005:00:00","MM/DD/YYYY:HH24:MI" and TO_DATE("01/01/2010:00:00","MM/DD/YYYY:HH24:MI")
and customer_age between 13 and 18

I get some correct results, but I also get people who transacted in 2005 at 18 (making them 25 now)

and((customer_age=13 and trans_date BETWEEN TO_DATE('01-JAN-2005:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2005:23:59','DD-MON-YYYY:HH24:MI'))
or (customer_age=14 and trans_date BETWEEN TO_DATE('01-JAN-2006:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2006:23:59','DD-MON-YYYY:HH24:MI'))
or (customer_age=15 and trans_date BETWEEN TO_DATE('01-JAN-2007:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2007:23:59','DD-MON-YYYY:HH24:MI'))
or (customer_age=16 and trans_date BETWEEN TO_DATE('01-JAN-2008:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2008:23:59','DD-MON-YYYY:HH24:MI'))
or (customer_age=17 and trans_date BETWEEN TO_DATE('01-JAN-2009:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2009:23:59','DD-MON-YYYY:HH24:MI'))
or (customer_age=18 and trans_date BETWEEN TO_DATE('01-JAN-2010:00:00'.'DD-MON-YYYY:HH24:MI') and TO_DATE('31-DEC-2010:23:59','DD-MON-YYYY:HH24:MI')) )

But that returns an error saying I am missing a right paren.
1. What am I missing? and 2. Is there a more efficient way to do this?

EDIT: Forgot the second date and some other formatting things

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:05:41+00:00Added an answer on June 7, 2026 at 6:05 pm

    You need to calculate the current age, given the information you have. The idea is to add the number of years since the transaction to the age. I’m not great with Oracle datetime functions, but the following should work:

    select tl.*, 
    from trans_logs tl
    where customer_age + (SYSDATE- trans_Date)/365 = 20
    

    Do note this is an approximation, since you will get people who are about “20” depending on the relatinonship between their birthdate and the transaction date.

    It is better to bring in the birthdate, if you can. I do understand that asking people their age might be easier than asking people their birthdate, so you might not have a choice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to search for this specific thing I'd like to do, I end
I'm trying to perform a fulltext search with codeigniters built in Active Record methods.
I am trying to search for any string that contains ; in a column
I am trying to create a query in SQL Server that will search for
I'm trying to create a search where a single record must have multiple records
I am trying to visualize how to create a search for an application that
I'm trying to build a search engine that goes through online vehicle classifieds such
I am trying to form a query using codeigniter's active record, the search is
I have 2 tables: posts tags Tags table is structured like this: post_id tag
I am trying to update values that I use IQueryable to search my linq

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.