0

In my table case ,there are 2 tiemstamp fields looks like:

check_in                check_out
"2021-09-07 07:25:00"   "2021-09-08 17:10:00"
"2020-09-25 06:02:00"   "2020-09-27 15:20:00"
"2020-10-26 05:42:00"   "2020-10-29 13:05:00"

How can I query the rows that check_out - check_in larger than 2 days,something like:

select * from case where check_out - check_in > 2 days ;

Then output will be:

check_in                check_out
"2020-09-25 06:02:00"   "2020-09-27 15:20:00"
"2020-10-26 05:42:00"   "2020-10-29 13:05:00"
2
  • WHERE check_out - check_in > INTERVAL '2 days'; Commented Dec 13, 2022 at 19:22
  • 1
    A sidenote: Since "case" is a SQL key word, you should think about renaming this table. Commented Dec 13, 2022 at 19:36

1 Answer 1

4

You were close. You need to give a correct interval value

select * 
from case 
where check_out - check_in > interval '2 days';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.