How to add 1 second to an Oracle date?

Asked

Viewed 343 times

0

I am trying to search a table for a row that has the start_date in the second after the date placed.

 select * 
                    from    PAY_PERIOD
                    where   pay_period_schedule_id = 2 
                    AND  start_date = TO_DATE('2020-04-30 23:59:59','RRRR-MM-DD HH24:MI:SS') + 1
                    AND DELETED = 0 
                    ORDER BY end_date desc;

I’ve tried to add 1 as it is in the code but it doesn’t work if I have the time variables, minutes and seconds there. DATEADD does not exist for Oracle and I have tried adding with TO_DATE('00:00:01','HH24:MI:SS')

I want you to get the date 2020-05-01 00:00:00

1 answer

0

As soon as I published the question, it gave me light... I’ll leave it here for someone who might have the same doubt

select * 
                    from    PAY_PERIOD
                    where   pay_period_schedule_id = 2 
                    AND  start_date = TO_DATE('2020-04-30 23:59:59','RRRR-MM-DD HH24:MI:SS') + interval '1' second
                    AND DELETED = 0 
                    ORDER BY end_date desc;
  • or <data>+(1/86400)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.