1

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?

0

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

https://social.msdn.microsoft.com/Forums/en-US/109ae6f2-ea16-464f-978e-b565a69721a5/sharepoint-designer-2010-determine-if-todays-date-is-within-x-days-of-a-start-date-column-using?forum=sharepointcustomizationprevious

  • 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 Nov 27 '14 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 Nov 27 '14 at 13:32
0

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, privacy policy and cookie policy

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