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 3.12
sub units 6.68
+
0
UnitsDate

inc Month

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

Dependents

Info

Interface

C++

IncMonth

 
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: \inline  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

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.