I have a DataView Webpart, to display XML data using XML File connection.

I use the below formula to calculate the day difference between 2 dates:

"(number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(Date2)))) - number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(Date1))))) div 864000000000"

Now I would like to calculate the Hours and minutes difference between the 2 dates. I'm scratching my head to achieve this. Can anyone help me with this?

2 Answers 2


If you div by 864000000000 you will get Days.

In order to get Hours you can use the same formula with div by 36000000000 and for minutes div by 600000000

ddwrt:DateTimeTick function returns the number of “ticks” since Jan 1 1900


  • This didnt work as i expected. It simply multiples the day X 24. What i am looking for is, I have a start date and time : 11/2/2014 14:00:00 and a end date time : 11/27/2014 16:00:00.I need to calculate the time difference between the two times and display the result as 2 hours.Is it possible?
    – George
    Commented Nov 27, 2014 at 13:21
  • With the above formula,it displays only the hours greater than 1 day and that too as a whole hours for a day namely 24(1*24),48(2*24),72(3*24),etc and not exactly the time difference between 2 times.
    – George
    Commented Nov 27, 2014 at 13:32

Here is a post that has helped me in the past with very similar challenges.

It has a hyperlink to an XSL document that contains several templates for date arithmetic operations. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.