12 Replies Latest reply: Sep 30, 2013 6:39 AM by ascheffer

# Calculate month

How to calculate the month from day1 to day25 ?

Sanjay

• ###### 1. Re: Calculate month

what do you mean by calculate the month from day1 to day25 ?

• ###### 2. Re: Calculate month

Each month will be from 26th day of current month to 25th day of next calender month.

Example : 26th August 2013       to 25th September will be September month (Sep-2013). Like wise

26th September 2013 to 25th October     will be October month (Oct-2013)

Sanjay

• ###### 3. Re: Calculate month

Hi,

30day=1month

25day=x

x=1month*25day/30day =0.83month

Thank you

• ###### 4. Re: Calculate month

Are you looking for Months between two date?

SELECT MONTHS_BETWEEN (to_date('26-SEP_2013','DD-MON-YYYY') ,to_date('26-AUG_2013','DD-MON-YYYY'))  from DUAL;

• ###### 5. Re: Calculate month

What inputs do you have, and what output are you hoping to achieve?

For example, if you're starting with a particular month and want to know the start and end date, you could do this:

SELECT ADD_MONTHS (TO_DATE ('SEP-2013', 'MON-YYYY') + 25, -1) Start_Date,

TO_DATE ('SEP-2013', 'MON-YYYY') + 24 End_Date,

TO_DATE ('SEP-2013', 'MON-YYYY') + 24 + 86399/86400 End_Date_inc_Time

FROM   DUAL

Obviously, you'd have some kind of parameter instead of hard-coding 'SEP-2013'

• ###### 6. Re: Calculate month

30day=1month

Really? You might want to double-check the calendar before making such sweeping generalisations about the length of months.

• ###### 7. Re: Calculate month

Yes 30day=1 month

• ###### 8. Re: Calculate month

AnarGodjaev wrote:

Yes 30day=1 month

I have seen 28, 29, 30 and 31 days in a month!!

• ###### 9. Re: Calculate month

Please read Re: 2. How do I ask a question on the forums? from FAQ to know the details you need to provide while framing a question.

• ###### 10. Re: Calculate month

select the_month,min(the_day) day_from,max(the_day) day_to

from (select to_date('26.9.2013','dd.mm.yyyy') + level - 1 the_day,

to_char(add_months(to_date('26.9.2013','dd.mm.yyyy') + level - 1 - 25,1),'Mon-yyyy') the_month

from dual

connect by level <= 456

)

group by the_month

order by day_from

Regards

Etbin

Message was edited by: Etbin Sorry, wrong destination

• ###### 11. Re: Calculate month

select the_month,min(the_day) day_from,max(the_day) day_to

from (select to_date('26.9.2013','dd.mm.yyyy') + level - 1 the_day,

to_char(add_months(to_date('26.9.2013','dd.mm.yyyy') + level - 1 - 25,1),'Mon-yyyy') the_month

from dual

connect by level <= 456

)

group by the_month

order by day_from

Regards

Etbin

• ###### 12. Re: Calculate month
```select to_char( the_day, 'dd/mm/yyyy' )
, to_char( trunc( the_day + case when to_char( the_day, 'dd' ) > '25' then 6 else 0 end, 'mm' ), 'Mon-yyyy' ) the_month
from ( select  sysdate - 10 + level the_day
from dual
connect by level < 60
)

```