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)

How to find difference between two utcdatatime field in the form of hours, min, sec?

(0) ShareShare
ReportReport
Posted on by 516

Hello,

i am stuck with this small problem that how to represent seconds in the form of days, hours, min, sec. means i am trying to find difference between two utcdatetime field so i tried this

mytime = datetimeutil::getDifference(MouldInfoTable.CreateDT,MouldInfoTable.CloseDT);

from this i get difference in the seconds form, but i dont know how to do in above form, i tried google but it is not working. if is there any solution apart from that or any mathod , please share, 

Thanks

akshay

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi,

    To calulate the difference in hours mins and seconds use this function DateTimeUtil :: getDifference but for example if you want to get the different in mins you have to divide the value from that function on 60 and so on.To calculate the difference in days weeks months years use this function intvNo(toDate, fromDate, intvScale::YearMonthDay) and change intvScale enum depending on the difference type day month year.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Hi akshaykupra,

    You can use this code to convert seconds to days, hours, minutes and seconds:

    info(strFmt('%1d:%2h:%3m:%4S', 
            (mytime div 86400), 
            ((mytime Mod 86400) div 3600), 
            ((mytime Mod 3600) div 60), 
            ((mytime Mod 3600) Mod 60)));


  • akshaykupra Profile Picture
    516 on at

    Hi,

    @ievgen : thank you so much, this is what i am looking for.

    @Kavitha : thank you for explaining and same thing done above.

    Thanks,

    Akshay

  • Suggested answer
    guk1964 Profile Picture
    10,888 on at

    Try the DateTimeUtil::getDifference Method to get the number of seconds between two specified utcdatetime values.  See: msdn.microsoft.com/.../datetimeutil.getdifference.aspx

     days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;

    Also see this useful reference post sujanadynamics.blogspot.ae/.../date-calculations.html

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