Home » SQL & PL/SQL » SQL & PL/SQL » SQL Query for Oracle Datatbase
SQL Query for Oracle Datatbase [message #420945] Thu, 03 September 2009 07:41 Go to next message
andysam23586
Messages: 17
Registered: September 2009
Junior Member
Hi

I have a table called CallsLogged with a column called EnteredOn.
The data in this column is a date in unix Time Stamp format.
I need to write a SQL query to retrieve all entries where the value of "EnteredOn" is Today.

At the minute the query looks like this:

SELECT *
FROM CallsLogged
WHERE EnteredOn BETWEEN DATEDIFF(Second, '19700101', DATEADD
                        (Day, DATEDIFF(Day, 0, CURRENT_TIMESTAMP), 0)) AND DATEDIFF
                        (Second, '19700101', DATEADD(Day, DATEDIFF(Day, 0, CURRENT_TIMESTAMP)+1, 0)) -1


This works great on a SQL Server Database but I need it to work on an Oracle Database.

I am getting the error 'DATEDIFF: invalid identifier'

Can anyone help translate this code into an oracle SQL query
Re: SQL Query for Oracle Datatbase [message #420948 is a reply to message #420945] Thu, 03 September 2009 07:55 Go to previous message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Database SQL Reference contains the list of Oracle SQL functions and DATEDIFF does not exist.
You can direclty subtract 2 dates in Oracle using minus sign.

Regards
Michel

[Updated on: Thu, 03 September 2009 07:57]

Report message to a moderator

Previous Topic: PRAGMA AUTONOMOUS_TRANSACTION
Next Topic: SQL Query to get a time index
Goto Forum:
  


Current Time: Wed Sep 28 16:00:30 CDT 2016

Total time taken to generate the page: 0.11073 seconds