The string output can be controlled, you can specify the notation with different parameters.
It goes something like this:
str date2Str(
date date,
int sequence,
int day,
int separator1,
int month,
int separator2,
int year
[, int flags = DateFlags::None])
In an example:
static void Example_date2str(Args _args) { ; info(date2str(systemdateget(),123,2,1,2,1,4)); }
But the documentation lacks a bit of details around the different separators to use.
The different options are all listed here, but the actual values to use in the date2Str function are omitted. The function requires an integer (or enum) as parameter for the date separator.
And not a char or string, like "/" or "-".
You can use the enum DateSeparator for this. This enum has following enumerations:
Name | Value | Description |
---|---|---|
Auto | 99 | Auto |
None | 0 | None |
Space | 1 | |
Dot | 2 | . |
Hyphen | 3 | - |
Slash | 4 | / |
This part of the documentation got updated with the newly released Ax 2012 version. So the missing info only applies to versions 3.0, 4.0 and 2009. (Like you can find both in Ax help system - see screendump above- or online at MSDN over here.)
Same example as above, but less cryptic:
static void Example_date2str(Args _args) { ; info(date2str(systemdateget(), 123, dateDay::Digits2, DateSeparator::Space, DateMonth::Digits2, DateSeparator::Space, DateYear::Digits4)); }Good to note here as well is that there is another way of setting the notation: Use the regional settings of the user.
For that, just set all the formatting parameters to -1.
Like this:
static void Example_date2str(Args _args) { ; info(date2str(systemdateget(),-1,-1,-1,-1,-1,-1)); }
Dynamics Ax actually has a predefined function for this in the Global class, being date2StrUsr.
static void Example_date2str(Args _args) { ; info(date2strUsr(systemdateget())); }This function depends on date2Str, just like in the example above. From the Ax source code:
static TempStr date2StrUsr(date transDate,int flags = DateFlags::None) { return date2str(transDate,-1,-1,-1,-1,-1,-1,flags); }
In AX 3.0 (SP3) the seperator enum is called 'DateSep' and has the following values:
ReplyDeleteName - Label - EnumValue
Slash '/' 0
Dash '-' 1
Dot '.' 2
Space ' ' 3
None '#' 4
best reagards
Timon
this functions comes from Concorde XAL, where separator description is full.
ReplyDeleteI really like you post,Thanks for your sharing.
ReplyDeleteดูหนังผี
Thank you for sharing your thoughts and knowledge on this topic.
ReplyDeleteMS Dynamics Technical Online Training
Thank you for sharing wonderful information with us to get some idea about it.
ReplyDeleteMicrosoft Dynamics AX Technical Training in Hyderabad
MS Dynamics Technical Online Training
MS Dynamics AX Technical Training in Hyderabad
MS Dynamics AX Online Training
D365 AX Online Training