Raj More Raj More - 1 year ago 68
SQL Question

Number of days in a month

I have a monthly amount that I need to spread equally over the number of days in the month. The data looks like this:

Month Value
----------- ---------------
01-Jan-2012 100000
01-Feb-2012 121002
01-Mar-2012 123123
01-Apr-2012 118239

I have to spread the Jan amount over 31 days, the Feb amount over 29 days and the March amount over 31 days.

How can I use PL/SQL to find out how many days there are in the month given in the month column?

Answer Source
SELECT CAST(to_char(LAST_DAY(date_column),'dd') AS INT)
  FROM table1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download