viewed 1476 times and licensed 3 times
Advances a serial date to the last day of the month after adding \a months.
Excel: EOMONTH
View version details
Contents  |
|
Interface
#include <codecogs/units/date/endofmonth.h>
using namespace Units::Date;
| int | endOfMonth (int nDate, int months, calendar dateSystem=cal_Gregorian)[inline] Advances a serial date to the last day of the month after adding months.
Excel: EOMONTH |
Function Documentation
Returns the serial Julian date which equals the last day of the month for
nDate plus or minus the offset provided by
months.
The
month is modified using:

. The
day part of
nDate is always overwritten with the maximum number of days in the new month.
Example 1:
#include <stdio.h>
#include <codecogs/units/date/endofmonth.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;
int main()
{
for(int i=-2; i<=2; i++)
{
int d,m,y;
dateYMD(endOfMonth(date("19,feb,2003"), i), y, m, d);
printf("\n Month end for 19 February 2003 + %d months is: %d-%d-%d",i, d, m, y);
}
for(int i=-2; i<=2; i++)
{
int d,m,y;
dateYMD(endOfMonth(date("31,dec,2004"), i), y, m, d);
printf("\n Month end for 31 December 2004 + %d months is: %d-%d-%d",i, d, m, y);
}
return 0;
}
Output:
Month end for 19 February 2003 + -2 months is: 31-12-2002
Month end for 19 February 2003 + -1 months is: 31-1-2003
Month end for 19 February 2003 + 0 months is: 28-2-2003
Month end for 19 February 2003 + 1 months is: 31-3-2003
Month end for 19 February 2003 + 2 months is: 30-4-2003
Month end for 31 December 2004 + -2 months is: 31-10-2004
Month end for 31 December 2004 + -1 months is: 30-11-2004
Month end for 31 December 2004 + 0 months is: 31-12-2004
Month end for 31 December 2004 + 1 months is: 31-1-2005
Month end for 31 December 2004 + 2 months is: 28-2-2005
- cal_Gregorian (default)
- cal_Julian
- cal_Excel (same as Gregorian)
Parameters:
| nDate | is the number of days from 24 November 4714 BC - otherwise known as the Julian Period (also 1 January 4713BC in the Julian Calendar). |
| months | are the number of months to add (a positive value) or subtract (a negative value) from nDate. |
| dateSystem | selects which date system should be used (see constants): |
Authors:
- Will Bateman (Sep 2004)
Page Comments
You must login to leave a messge
Last Modified: 18 Oct 07 @ 17:07 Page Rendered: 2010-03-09 03:21:51