Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need a way to substract to dates and get the result in days in sql.

I'm using PostgreSQL 8.4

share|improve this question

2 Answers 2

When both columns you want to subtract are of date type, you can just use the - operator.

Take a look at the documentation for date functions, in particular table 9-25.

share|improve this answer
1  
Please do not post links to outdated versions of postgres. Use docs/current/static/ instead of docs/8.1/static/ to link to the current version of postgres manual. –  Igor Romanchenko Aug 4 '14 at 15:24

Check here the documentation of PostgreSQl... postgresql.org/docs/8.4

I copied it from this code from this website:

age(timestamp '2001-04-10', timestamp '1957-06-13')

hope it will help you...

share|improve this answer
    
will not work. Check select extract(day from age(timestamp '2001-04-10', timestamp '1957-06-13')); –  Clodoaldo Neto Aug 4 '14 at 14:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.