Let’s say you have two dates and want to know how many days there are between these two dates. Searching through Dynamics AX developers help you will find that there is an explicit conversion called date2int. This sounds reasonable, we do want to convert our date to an int to get the number of days.
But if you try to use date2int you will find that this will generate an error when compiling that says:
This function has not been declared
Obviously date2int does not work as the developer help suggests. But what does?
It did some digging without any success until one of my colleagues suggested that I try date2num instead. This command is used in XAL for the exact same purpose. Sure enough this worked just fine.
Example code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | static void FO_date2num(Args _args) { date date1 = systemDateGet(); // Today date date2 = systemDateGet() - 1; // Yesterday int i; ; // Today - Yesterday i = date2num(date1) - date2num(date2); print i; pause; } |
Printout:
1
Last 5 posts in Development
- No valid document identified from the entity key - April 9th, 2010
- Using Regular Expressions in Dynamics AX - October 2nd, 2009
- Create class and methods in x++ - December 22nd, 2008
- Simple field lookup in form - October 13th, 2008
- Get your Intercompany CustAccount - September 29th, 2008