locked
Calculate Date Difference RRS feed

  • Question

  • Hello, I am working with a Content Manager Solution called SpringCM.

    I it I have Adwanced workflow creator with Expression Editor.

    The thing is that at the moment i have two dates: one is document creation date and other notification date.

    They both are variables.

    I wanted to know how to calculate the difference between these two dates (variables) with output: (ddd.hh:mm:ss)

    Any help would be much appreciated.

    Thursday, November 6, 2014 2:19 PM

Answers

  • Here is a simple example:

                DateTime dt1 = new DateTime(2014, 11, 15, 12, 0, 0);
                DateTime dt2 = new DateTime(2014, 11, 15, 10, 50, 1);
    
                TimeSpan ts = dt2 - dt1;
                string result = string.Format("The difference is: {0:ddd\\.hh\\:mm\\:ss}", ts);


    • Edited by Mr. Zator Thursday, November 6, 2014 2:34 PM
    • Proposed as answer by Andy ONeill Thursday, November 6, 2014 2:47 PM
    • Marked as answer by Kristin Xie Tuesday, November 18, 2014 8:43 AM
    Thursday, November 6, 2014 2:34 PM