CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

UnitsDate

inc Month

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 2.60
sub units 6.50
add a commercial licence to your cart
0
viewed 1204 times and licensed 10 times

Advances a serial date by a number of \a Months. Excel: EDATE

Further Info Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     get GPL     add to cart

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

 
intincMonthintnDate
intmonths
calendardateSystem = cal_Gregorian )[inline]
Returns the serial Julian date which equals nDate plus or minus the the specified number of months.

The month is modified using: Month_{new} = Month_{old} + Months. 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:
nDateis the number of days from 24 November 4714 BC - otherwise known as the Julian Period (also 1 January 4713BC in the Julian Calendar).
monthsare the number of months to add (a positive value) or subtract (a negative value) from nDate.
dateSystemselects which date system should be used (see constants).
Authors:
Will Bateman (Sep 2004)
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

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


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 10 Apr 08 @ 20:51     Page Rendered: 2010-03-15 08:28:03

Valid CSS!   Valid XHTML 1.0 Transitional