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

Valid RSS

UnitsDate

end Of Month

Only available under a commercial licence
COST (GBP)
this unit 2.34
sub units 6.50
add a commercial licence to your cart
0
viewed 1476 times and licensed 3 times

Advances a serial date to the last day of the month after adding \a months. Excel: EOMONTH

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

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

 
intendOfMonthintnDate
intmonths
calendardateSystem = cal_Gregorian )[inline]
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: Month_{new} = Month_{old} + Months. 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

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 to buy a Commercial licence.

buy now     add 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: 18 Oct 07 @ 17:07     Page Rendered: 2010-03-09 03:21:51

Valid CSS!   Valid XHTML 1.0 Transitional