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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Conversion to hours

(0) ShareShare
ReportReport
Posted on by 61

Hello there,


What should I do to get results in hours when I receive the difference of the two fields that are ExtendedDataType SechedFromTime?

Ex: StartHour - EndHour : 12:30 

3122.pastedimage1564499906197v4.png

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    Subtract StartHour from EndHour and converted the result to a formatted string with time2StrHM().

  • Suggested answer
    Mehmet Ali Akbulut Profile Picture
    61 on at

    This field is displayed. Result from the following code : Example : 3,67 hour

    But i want result: 4:07 hour

    3302.prod.png

    server display Hours TotalTime()

    {

       DRT_ProdOpReportTrans   ProdOpReportTrans;

       Hours   hours = 0;

       ;

       while select ProdOpReportTrans

               index hint ProdLineIdx

               where ProdOpReportTrans.ProdId     == this.ProdId

         if(ProdOpReportTrans.End == NoYes::Yes || ProdOpReportTrans.Start == NoYes::Yes )

         {

           hours = (ProdOpReportTrans.dispEndProdHour() - ProdOpReportTrans.dispStartProdHour()) / str2Time('00:60');

         }

      return hours;

    }

    How can I do that?

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    I already gave you the answer in my first reply - use time2StrHM(). Here is a concrete example:

    timeOfDay time1 = timeNow();
    timeOfDay time2 = time1 + 90*60;
    str s = time2StrHM(time2 - time1);

    By the way, it makes no sense to use a while select if you always return just the last value. Either you wanted to do an aggregation and you forgot, or you added the loop by mistake. Also, your checks for Start and End should be in  the query - you're wasting resources to fetch records you don't want.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans