viewed 2269 times and licensed 42 times
Computes the number of days between two serial dates using a 360 day accounting years.
Excel: DAYS360
View version details
Contents  |
|
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
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,
| Type | Description |
| dd_Europe | Start or end dates that occur on the 31st of a month become equal to the 30th of the same month. |
| dd_USA | This 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:
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;
}
- dd_European
- dd_USA (default)
Parameters:
| startDate | and... |
| endDate | are 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. |
| type | defines which accounting date system to use: |
Page Comments
You must login to leave a messge
Last Modified: 10 Apr 08 @ 20:54 Page Rendered: 2010-02-09 19:14:18