Announcements
No record found.
I have two fields Date type, i would like about how to calculate time among them 2 using JavaScript
*This post is locked for comments
In addition to what Guido states, you'll have to take some other things into account...
My code
var dt1= Xrm.Page.getAttribute("new_date1").getValue();
var dt2= Xrm.Page.getAttribute("new_date2").getValue();
var h= Xrm.Page.getAttribute("new_hours").getValue();
var hours = 60*60*1000;
if (date1!= null && date2!=null) {
var diffHours = Math.round(Math.abs((dt2.getTime() - dt1.getTime())/(hours)));
}
h.setValue(diffHours );
------
but don't working
Thanks so much! I need to pay more attention XD
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.