Selecting record based on TIMESTAMP column in oracle

30 Views Asked by At

I have the table contains column create_datetime.It is timestamp(6) data type.

I used the below query to fetch the create_datetime-15 days records

The table having records for this condition But it is not listing for below query

SELECT create_datetime 
FROM xy
WHERE create_datetime <= create_datetime-15 
2

There are 2 best solutions below

2
Bohemian On BEST ANSWER

Specify the units of the subtraction:

create_datetime - NUMTODSINTERVAL(15, 'DAY')
0
Yoji On

You can try this:

SELECT create_datetime 
FROM xy
WHERE create_datetime <= DATE_SUB(create_datetime, INTERVAL 15 DAY);

Let me know if this help you!