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

Valid RSS

UnitsDate

date Diff360

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 1.56
sub units 3.90
add a commercial licence to your cart
0
viewed 2269 times and licensed 42 times

Computes the number of days between two serial dates using a 360 day accounting years. Excel: DAYS360

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

Interface

#include <codecogs/units/date/datediff360.h>

using namespace Units::Date;

int dateDiff360 (int startDate, int endDate, dateDiffType type=dd_USA)
Computes the number of days between two serial dates using a 360 day accounting years. Excel: DAYS360

Function Documentation

 
intdateDiff360intstartDate
intendDate
dateDiffTypetype = dd_USA )
Returns the number of days between two serial Julian dates based on a 360-day year (twelve 30-day months), which is used in some accounting calculations, where each month is assumed to have 30-days. You might use this function to compute employee payments if your accounting system is based on twelve 30-day months.

To facilitate the new month lengths, the dates entered may need to be adjusted, such that months with 31 days are assumed to have 30, while February is extended. These calculation are performed within the confines of the Gregorian calendar, nevertheless Europe and the USA each have their own methodologies for adjusting dates that occur at the end of the month,
TypeDescription
dd_EuropeStart or end dates that occur on the 31st of a month become equal to the 30th of the same month.
dd_USAThis is identical to the European system with one exception that applies only to end dates: If the end date occurs on the 31st of a month it is moved to the 1st of the next month if the start date is earlier than the 30th. This method is sometime also called the 'NASD' method.

Having made these adjustments to the start and end dates, the difference between these is calculated using:
dateDiff = \begin{array}{l} \left (day_{end} + 30 month_{end} + 360 year_{end} \right ) \\ - \left (day_{start} + 30 month_{start} + 360 year_{start} \right ) \end{array}
where the subscripts refer to the start and end date with attributes day, month, and year.
Example 1:
#include <stdio.h>
#include <codecogs/units/date/datediff360.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;
 
int main()
{
  printf("\n Diff 360=%d days", dateDiff360(date("27-2-2004"), date("20-8-2005")));   // 533
  printf("\n Diff 360=%d days", dateDiff360(date("28-2-2004"), date("20-8-2005")));   // 532
  printf("\n Diff 360=%d days", dateDiff360(date("29-2-2004"), date("20-8-2005")));   // 530
  printf("\n Diff 360=%d days", dateDiff360(date("1-3-2004"),  date("20-8-2005")));   // 529

printf("\n\n Diff 360=%d days", dateDiff360(date("29-3-2004"), date("20-8-2005"))); // 501 printf("\n Diff 360=%d days", dateDiff360(date("30-3-2004"), date("20-8-2005"))); // 500 printf("\n Diff 360=%d days", dateDiff360(date("31-3-2004"), date("20-8-2005"))); // 500 printf("\n Diff 360=%d days", dateDiff360(date("32-3-2004"), date("20-8-2005"))); // 499

printf("\n\n Diff 360=%d days", dateDiff360(date("15-3-2004"), date("30-10-2005")));// 585 printf("\n Diff 360=%d days", dateDiff360(date("16-3-2004"), date("31-10-2005"))); // 585 printf("\n Diff 360=%d days", dateDiff360(date("29-3-2004"), date("30-10-2005"))); // 571 printf("\n Diff 360=%d days", dateDiff360(date("31-3-2004"), date("31-10-2005"))); // 570

printf("\n\n Diff 360=%d days", dateDiff360(date("28-2-2004"), date("31-10-2005")));// 603 printf("\n Diff 360=%d days", dateDiff360(date("29-2-2004"), date("31-10-2005"))); // 601 return 0; }

Parameters:
startDateand...
endDateare serial Julian dates (see date ). The return value is signed, so if startDate occurs before endDate then a negative answer will be returned. See date , for details on creating these numbers.
typedefines which accounting date system to use:
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:54     Page Rendered: 2010-02-09 19:14:18

Valid CSS!   Valid XHTML 1.0 Transitional