Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Expression Assistant - Calculate TotalHours from two dates
posted

Hi

I need to calculate the number of hours between two dates.

Is this possible or do I have to bring it in from my datasource?

Kr George

Parents
  • 550
    posted

    Hi George,

     

    You can use the the minus "-" operator that can subtract also date types.

    For example:

    = Date2 - Date1                                          // Difference in days
    = (Date2 - Date1) * 24                               // Difference in hours
    = (Date2 - Date1) * 24 *60                        // Difference in minutes
    = (Date2 - Date1) * 24 *60 * 60                // Difference in seconds
    = (Date2 - Date1) * 24 *60 * 60 * 1000   // Difference in milliseconds

    If you want to truncate the result, you can do the following:

                  = (<<expression>>) \ 1

    For example (current hour):

                  =((Variables.Now - Variables.Today) * 24) \ 1

     

    I hope this helps.

    regards,

    Simon

Reply Children