Reputation: 120
As the title suggests, I'm simply trying to get the result set between midnight today and right now. So given the time of this post, I want data between 06/30/16 00:00:00 and 06/30/16 15:52:00. Why does the below query not return anything? Thanks.
SELECT * FROM tableName
WHERE event_date >= TO_DATE(TRUNC(SYSDATE) || ' 00:00:00', 'DD-MON-YY HH24:MI:SS')
AND event_date <= TO_DATE(TRUNC(SYSDATE))
Upvotes: 1
Views: 2596
Reputation: 120
The solution was as follows:
SELECT * FROM tableName
WHERE event_date >= TO_DATE(TRUNC(SYSDATE))
I had forgotten that TRUNC(**SYSDATE)** by itself is perceived as midnight unless otherwise specified, so this does the trick.
Upvotes: 0
Reputation: 167867
SELECT *
FROM tableName
WHERE event_date BETWEEN TRUNC(SYSDATE) AND SYSDATE;
Upvotes: 3