Wednesday, 21 November 2012
Work with Date format in AX 2009
Hi Developers,
you can use the following code for changing the format of date in ax
dt=today();
datestr(dt,123,2,4,2,4,2);
here
dt is todaysdate,
OR
datestr(Date_Field_Name,123,2,4,2,4,2);
"123" means,1 for day,2 for month,3 for year,u can also reorder these
"2" for printing the day or month or year as per u r chosen format
"4" for seperator like /,-, etc whatever u want
"2" for month
"4" for seperator
"2 "for year
------------------------------------------------------------------------------------------------
When you need to convert from date to string in x++ it's need many parameters in the function that convert from date to string i'll explain with simple example :
void DateTStringConvert()
{
date today=today();
str TodayDate;
;
TodayDate = date2str( today,321,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4);
info(TodayDate );
}
Note :
The function date2str take following parameters :
1- the date .
2- the date style dmy or ymd or....etc .
3- number of digits for day .
4- separator
5- number of digits for month.
6- separator
7- number of digits for year.
now you can use the date as string
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment