Hello :)
is there any function in ax 2012 help me to calculate days between 2 dates using a 360 day year
Thanks
*This post is locked for comments
Hi Source258147,
Can you explain me what a 360 day year means for you? The date calculation provided by Crispin is using the Gregorian calendar.
Thanks Crispin John Augustine for the help
but i want 360 days per year not 365
Thanks André Arnaud de Calavon for the help
this is for customization porpose
i need some thing like this
www.techonthenet.com/.../days360.php
this is the function in excel calc days in years as 360 days not 365 days
Hi source258147,
Or you have to find a component (dll) which can do help you, or you need to write your own function for this calculation. It is not a standard function in x++.
Thanks André Arnaud de Calavon :)
Based on this article, I have created an x++ method. You can copy it and test it in your environment. Based on various calculation methods available, you can adjust the coding a bit. Please test carefully, I'm not liable for any wrong days calculation. Use it at your own risk.
public static Days Days360(StartDate _startDate, EndDate _endDate, boolean _european = false) { int year1, year2; int month1, month2; int day1, day2; ; year1 = Year(_startDate); year2 = Year(_endDate); month1 = mthOfYr(_startDate); month2 = mthOfYr(_endDate); day1 = dayOfMth(_startDate); day2 = dayOfMth(_endDate); if (_european) { // European: Starting and ending dates on the 31st become the 30th. if (day1 == 31) { day1 = 30; } if (day2 == 31) { day2 = 30; } } else { // US: If both start and end dates are last day of february, set day2 to 30 if (month1 == 2 && dayOfMth(_startDate + 1) == 1 && month2 == 2 && dayOfMth(_endDate + 1) == 1) { day2 = 30; } // US: If start date is last of february, set day1=30 if (month1 == 2 && dayOfMth(_startDate + 1) == 1) { day1 = 30; } // US: If day1 is 30 or 31 and day2 is 31, set day2 to 30 if (day2 == 31 && day1 >= 30) { day2 = 30; } // US: If day1 is 31, set day1 to 30 if (day1 == 31) { day1 = 30; } } // Add it all together and return return 360*(year2-year1) + 30*(month2-month1) + (day2-day1); }
Hi Crispin,
The 360 day calendar is often used in the financial/banking sector, but there are some variants. You can read about it on the page I shared above, but also Wikipedia. It is a method to have e.g. an equal amount of interest for each month.
Thanks, André Arnaud de Calavon :)
I really appreciate your time and effort to help me
I test it in many scenarios and it works perfectly with me in many cases
I just did a small calculation. I add "+1" to get the same result like DAYS360 function in excel https://www.techonthenet.com/excel/formulas/days360.php
this is the code i use it if anyone like to test it in Job
static void Job143(Args _args) { int year1, year2; int month1, month2; int day1, day2; StartDate _startDate = mkdate(31,12,2013); EndDate _endDate = mkdate(28,02,2019); boolean _european = false; year1 = Year(_startDate); year2 = Year(_endDate); month1 = mthOfYr(_startDate); month2 = mthOfYr(_endDate); day1 = dayOfMth(_startDate); day2 = dayOfMth(_endDate); if (_european) { // European: Starting and ending dates on the 31st become the 30th. if (day1 == 31) { day1 = 30; } if (day2 == 31) { day2 = 30; } } else { // US: If both start and end dates are last day of february, set day2 to 30 if (month1 == 2 && dayOfMth(_startDate + 1) == 1 && month2 == 2 && dayOfMth(_endDate + 1) == 1) { day2 = 30; } // US: If start date is last of february, set day1=30 if (month1 == 2 && dayOfMth(_startDate + 1) == 1) { day1 = 30; } // US: If day1 is 30 or 31 and day2 is 31, set day2 to 30 if (day2 == 31 && day1 >= 30) { day2 = 30; } // US: If day1 is 31, set day1 to 30 if (day1 == 31) { day1 = 30; } } // Add it all together and return // add +1 info(strFmt("%1", (360*(year2-year1) + 30*(month2-month1) + (day2-day1))+1)); }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Community Member 4
Nayyar Siddiqi 2
NNaumenko 2