Jan 10, 2012

working with dates in axapta

Today i would like to discuss how to print the date in different formats.
have a look into the following code you will have an idea about the date formats in axapta.

static void Job1(Args _args)
{
    date currentDate = today();
    str s;
    int iEnum;
    ;
    s = date2Str
        (currentDate,
        321,
        DateDay::Digits2,

        DateSeparator::Hyphen, // separator1
        DateMonth::Digits2,
        DateSeparator::Hyphen, // separator2

        DateYear::Digits4
        );
    info("Today is:  " + s);
}

it will give the following output

/** Example Infolog output
Message (12:36:21 pm)
Today is:  2009-01-13
**/

Here the sequence parameter values must be any three digit number that contains exactly one occurrence of each digit 1, 2 and 3. The digits 1-2-3 represent day-month-year respectively. For example, 321 would produce the sequence of year, month, and day.

No comments: