I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 1.40
sub units 1.40
+
0
UnitsDate

days In Month

viewed 4675 times and licensed 185 times
Returns the number of days in the month of a Gregorian calendars. Open Office: DAYSINMONTH
Controller: CodeCogs

get GPL add to cart

Dependents

Info

Interface

C++
Excel

DaysInMonth

 
intdaysInMonthintyear
intmonth )
Returns the number of days in the months of a Gregorian calendar for the month of year. The year is used to apply adjustments for leap years.

Each month has a fixed number of days, except in a leap year, when February gains an extra day. Although we traditionally treat the 29th February as the leap day, a left over remnant of the Roman calendar means that the theoretical leap day occurs on the 24th February - many celebrations occur on this day for this reason.

The number of days in each month of the Gregorian / Julian calendar are: <div style="margin-left:100"> <table border="0" cellpadding="0" cellspacing="0"> <tr><td width="100"> January</td><td width="50">31</td></tr> <tr><td> February</td><td>28/29</td></tr> <tr><td> March</td><td>31</td></tr> <tr><td> April</td><td>30</td></tr> <tr><td> May</td><td>31</td></tr> <tr><td> June</td><td>30</td></tr> <tr><td> July</td><td>31</td></tr> <tr><td> August</td><td>31</td></tr> <tr><td> September</td><td>30</td></tr> <tr><td> October</td><td>31</td></tr> <tr><td> November</td><td>30</td></tr> <tr><td> December</td><td>31</td></tr> </tr> </table> </div>

Example 1

To output the number of days in each month of 1974
#include <stdio.h>
#include <codecogs/units/date/daysinmonth.h>
 
int main()
{
  for(int i=1;i<=12;i++)
    printf("\n Month %d has %d days",i , Units::Date::daysInMonth(2004,i));
  return 0;
}

Parameters

yearcan be any integer greater than 4800 BC (see isLeapYear).
monthcan be any integer between 1 and 12 (inclusive).

Authors

Will Bateman (Sep 2004)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.