Number of days in a month

Raj More picture Raj More · Dec 7, 2012 · Viewed 56.8k times · Source

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

a1ex07 picture a1ex07 · Dec 7, 2012
SELECT CAST(to_char(LAST_DAY(date_column),'dd') AS INT)
  FROM table1