postgresql - SQL Count days till first of the month -



postgresql - SQL Count days till first of the month -

how count days date till first of next month

example:

--start date 07-07-2011

how many days till:

-- 1st of succeeding month of start date above 08-01-2011

expected result (in days):

25

so if counted day 25, running query gets me desired timestamp:

select current_date + interval '25 days'

results:

2011-08-01 00:00:00

just can't think of way number of days, suggestions?

or start date, end date, number of days between?

i don't have postgresql server handy, untested, try:

select (date_trunc('month', current_date) + interval '1 month') - current_date

sql postgresql datetime

Comments

Popular posts from this blog

c# - Move local mssql database to webhosted MYSQL -

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -