postgresql - how to calculate only days between two dates in postgres sql query . -


suppose have given 2 dates, if difference 1 month should display 30 days.even months need convert days have tried age( date,now()::timestamp without time zone) giving months-dates-years format. ex: 10 mons 24 days 13:57:40.5265.but need following way. example if 2 months difference there need output 60 days.

don't use age() function date/time arithmetic. returns "symbolic" results (which enough human representation, meaningless date/time calculations; compared standard difference).

the standard difference operator (-) returns day-based results both date, timestamp , timestamp time zone (the former returns days int, latter 2 return day-based intervals):

from day-based intervals can extract days extract() function:

select current_date - '2017-01-01',        extract(day now()::timestamp - '2017-01-01 00:00:00'),        extract(day now()            - '2017-01-01 00:00:00z'); 

http://rextester.com/rbto71933


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -