2

I have two columns, say "2010-10-26" and "2010-08-23" and I would like to obtain the interval in days, what is the best way to do this on a select query taking into account that there are months with 30,31,29,28 days? Is there any function that already does this?

Thank you.

1

1 Answer 1

5

If they are already in the date format, it's very easy:

SELECT '10/26/2010'::date - '08/23/2010'::date;

OR:

SELECT date '2001-10-01' - date '2001-09-28'; // outputs integer 3
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.