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 636811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:33:20+00:00 2026-05-13T20:33:20+00:00

I am using oracle database. I want to execute one query to check the

  • 0

I am using oracle database. I want to execute one query to check the data between two dates.

NAME               START_DATE    
-------------    ------------- 
Small Widget       15-JAN-10 04.25.32.000000 PM      
Product 1          17-JAN-10 04.31.32.000000 PM  



select * from <TABLENAME> where start_date  
BETWEEN '15-JAN-10' AND '17-JAN-10'

But I don’t get any results from above query. I think I have to use "like" and "%". But I don’t know where to use them. Please throw some lights on this.

  • 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-05-13T20:33:20+00:00Added an answer on May 13, 2026 at 8:33 pm

    Judging from your output it looks like you have defined START_DATE as a timestamp. If it were a regular date Oracle would be able to handle the implicit conversion. But as it isn’t you need to explicitly cast those strings to be dates.

    SQL> alter session set nls_date_format = 'dd-mon-yyyy hh24:mi:ss'
      2  /
    
    Session altered.
    
    SQL>
    SQL> select * from t23
      2  where start_date between '15-JAN-10' and '17-JAN-10'
      3  /
    
    no rows selected
    
    SQL> select * from t23
      2  where start_date between to_date('15-JAN-10') and to_date('17-JAN-10')
      3  /
    
    WIDGET                          START_DATE
    ------------------------------  ----------------------
    Small Widget                    15-JAN-10 04.25.32.000    
    
    SQL> 
    

    But we still only get one row. This is because START_DATE has a time element. If we don’t specify the time component Oracle defaults it to midnight. That is fine for the from side of the BETWEEN but not for the until side:

    SQL> select * from t23
      2  where start_date between to_date('15-JAN-10') 
      3                       and to_date('17-JAN-10 23:59:59')
      4  /
    
    WIDGET                          START_DATE
    ------------------------------  ----------------------
    Small Widget                    15-JAN-10 04.25.32.000
    Product 1                       17-JAN-10 04.31.32.000
    
    SQL>
    

    edit

    If you cannot pass in the time component there are a couple of choices. One is to change the WHERE clause to remove the time element from the criteria:

    where trunc(start_date) between to_date('15-JAN-10') 
                                and to_date('17-JAN-10')
    

    This might have an impact on performance, because it disqualifies any b-tree index on START_DATE. You would need to build a function-based index instead.

    Alternatively you could add the time element to the date in your code:

    where start_date between to_date('15-JAN-10') 
                         and to_date('17-JAN-10') + (86399/86400) 
    

    Because of these problems many people prefer to avoid the use of between by checking for date boundaries like this:

    where start_date >= to_date('15-JAN-10') 
    and start_date < to_date('18-JAN-10')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.