Skip to content
Advertisement

filter timestamp column in SQL Oracle

I have a table with a Timestamp column which I need to filter after ‘2020-08-26’, but every solution won’t work

I tried the below queries:

WHERE CAST (RUN_DATE AS DATE) >= TO_DATE('2020-08-26', 'yyyy-mm-dd')

WHERE to_date(RUN_DATE, 'YYYY-MM-DD hh24:mi:ss') >= to_date('26-08-2020 23:59:59', 'YYYY-MM-DD hh24:mi:ss')

WHERE RUN_DATE >= TO_TIMESTAMP('26-08-2020 23:59:59')

Advertisement

Answer

Use a TIMESTAMP literal:

or, use a DATE literal:

or, use TO_TIMESTAMP with a format model:

or, use TO_DATE with a format model:

Which for the sample data:

All output:

| RUN_TIME                  |
| :------------------------ |
| 27-AUG-20 00.00.00.000000 |

db<>fiddle here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement