viewed 1204 times and licensed 10 times
Advances a serial date by a number of \a Months.
Excel: EDATE
View version details
Contents  |
|
Interface
#include <codecogs/units/date/incmonth.h>
using namespace Units::Date;
| int | incMonth (int nDate, int months, calendar dateSystem=cal_Gregorian)[inline] Advances a serial date by a number of Months.
Excel: EDATE |
Function Documentation
Returns the serial Julian date which equals
nDate plus or minus the the specified number of
months.
The
month is modified using:

. In circumstances where the new date has too many days for the month, the number of days are reduced to accommodate the month. For example: edate("30/March/2004", -1) is 29 February 2004.
Example 1:
#include <stdio.h>
#include <codecogs/units/date/incmonth.h>
#include <codecogs/units/date/date.h>
#include <codecogs/units/date/dateymd.h>
using namespace Units::Date;
int main()
{
for(int i=-12; i<=12; i++)
{
int d,m,y;
dateYMD(incMonth(date("31,dec,2004"), i), y, m, d);
printf("\n incMonth(date(\"31,dec,2004\"),%d)= %2d-%2d-%d",i, d, m, y);
}
return 0;
}
Output:
19 February 2003 + -4 months is: 19-10-2002
19 February 2003 + -3 months is: 19-11-2002
19 February 2003 + -2 months is: 19-12-2002
19 February 2003 + -1 months is: 19-1-2003
19 February 2003 + 0 months is: 19-2-2003
19 February 2003 + 1 months is: 19-3-2003
19 February 2003 + 2 months is: 19-4-2003
19 February 2003 + 3 months is: 19-5-2003
19 February 2003 + 4 months is: 19-6-2003
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: 10 Apr 08 @ 20:51 Page Rendered: 2010-03-15 08:28:03