FUNCTION
dateDiff360
Computes the number of days between two serial dates using a 360 day accounting years. \begin{html}<span align="right" style="background-color:99FF99"><strong>Excel: DAYS360</strong></span>\end{html}
You're viewing an older version of this page (#193). View the current version.
Interface
#include <codecogs/units/date/datediff360.h>
using namespace Units::Date;
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, \copydoc date/constants dateDiffType
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;
}Parameters
- dd_European
- dd_USA (default)