web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Hours value not getting assigned to HH:MM type field

(0) ShareShare
ReportReport
Posted on by 330

Hi,

 

I have created a time field with format hh:mm but the place from where I am retrieving value for this field is returning Hours type value.

 

When i am assigning hours value in this field, it is not getting assigned.

 

Maybe this is because its format is HH:MM and I am assigning hours.

How to convert this Hours value to HH:MM format?

 

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Please show us what you're doing.

  • André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at

    Hi Yunus,

    You can try this:

    myTable.Time = DateTimeUtil::addHours(time, hours);

    or use functions like str2time()

  • Community Member Profile Picture
    on at

    If you are getting time in hours , you can take value before decimal as hour and can calculate minutes as per the other part.

    eg: 13.60 hr --> 13:36 (13 hour 36 minutes)  

    basically, 60 * (60/100)

  • Community Member Profile Picture
    on at

    Time fields store the time in milliseconds I believe. So if you want to store given hours you have to convert them to milliseconds manually by multiplying or as others mentioned with a function.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Time data type represents time is seconds (not miliseconds) since midnight. Nevertheless I'm still not sure what's Yunus's problem, so might be off-topic.

  • Yunus Shaik Profile Picture
    330 on at

    I have created a table field which stores time in HH:MM format.

    I am invoking a standard method for storing value in this custom field.

    But this standard method's return type is Hours so the return value is not getting assigned in my table's custom field.

    Do I need to change the field's datatype to string and append the return value with :00 for this?

  • Verified answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Let me try to fill some gaps in your description and please confirm that I did it right:

    The type of your field is timeOfDay.

    The type of Hours is int, representing a number of hours.

    You're trying to assign the int value to the timeOfDay field, which obviously can't work without conversion.

    If it's the case, you have to multiply the number of hours with number of seconds in an hour (use #TimeConstants macro). Also, if the number of hours may be higher than 23, you should normalize it before the conversion (it can be easily done with the mod operator).

  • Yunus Shaik Profile Picture
    330 on at

    Yes Martin, you are right.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans