Solved

Syntax for How to Search Between Dates in Oracle

Posted on 2011-09-23
2
531 Views
Last Modified: 2012-05-12
I am attempting to query an Oracle database, and I am new to Oracle syntax. (I am used to MS SQL Server and the local functions for that DBMS.) When I am attempting to search for all transactions that occurred between the dates of 9/1/2011 and 9/5/2011, I am ending up with the error message:
"SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action:"

The SQL code that I am attempting to use is listed below:
"Select * From results r Where r.txn_date BETWEEN todate('09/01/2011','mm/dd/yyyy') AND todate('09/05/2011','mm/dd/yyyy')"

Any help that could be provided would be greatly appreciated.
0
Comment
Question by:thenthorn1010
  • 2
2 Comments
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 36588830
Please correct todate () into to_date()
0
 
LVL 15

Accepted Solution

by:
Devinder Singh Virdi earned 500 total points
ID: 36588836
Here is the corrected one:-

Select * From results r Where r.txn_date BETWEEN to_date('09/01/2011','mm/dd/yyyy') AND
to_date('09/05/2011','mm/dd/yyyy')
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.

Question has a verified solution.

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

Suggested Solutions

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.
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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…

914 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

13 Experts available now in Live!

Get 1:1 Help Now