Search code examples
type-conversiondynamics-ax-2012

Conversion from integer to time in ax 2012


I have requirement where i find the type of field and then i show the value of that field, I am using SysDictField.baseType() method to get the type of the field and table.(field) will give me the value but if the field type is Time and when i try to fetch the type using baseType() method it gives me as an Integer so it gives me value like 72000, 62000 etc.. instead of 6.00 PM, 7.00 AM etc.. I want to convert the integer value to Time type so i can display 6.00 PM, 7 AM. Please help me.


Solution

  • The AX TimeOfDay type is number of seconds from midnight.

    You can use time2Str function or use div and mod operand to calculate hours and minutes.

    Example:

    info(time2Str(31501, TimeSeparator::Colon, TimeFormat::AMPM));