How would I count the days from a date till the first of the following month
--Start Date 07-07-2011
How many days till:
-- The 1st of the succeeding month of the start date above 08-01-2011
Expected Result (in days):
So if I counted the day I get 25, so running this query gets me the desired timestamp:
SELECT CURRENT_DATE + INTERVAL '25 DAYS'
just can't think of a way to get the number of days, any suggestions?
Or start date, end date, number of days between?Answer1:
I don't have a PostgreSQL server handy, so this is untested, but I would try:
SELECT (DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 MONTH') - CURRENT_DATE