Negative interval(day to second) to positive

Hi Team,

I'm having a function which calculates the time difference between a date time( output of a rule) and now(). then applying hour() to find how many hours it differing. But incase I'm checking this at 06-11-2023 7:00 am(output of rule) and my current time is also today 7 am , it generating Interval (Day to second) in negative like  -0::00:06:37.727 due to millisecs difference, so while taking hour for this converting 0 hour to 23 . but what I need is  0::00:06:37.727. so that my hour difference calculation will return 0. Anyone know how to do the conversion or any better solution?


Thanks in advance

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    In Appian, the difference between two dates is called an interval. Intervals are stored as decimals internally. This means, you can use the abs() function to get the positive value.

    Some example code below:

    a!localVariables(
      local!firstDate: datetime(2023, 11, 6, 7, 0, 0, 0),
      local!secondDate: datetime(2023, 11, 6, 7, 1, 0, 0),
    
      tointervalds(
        abs(
          todecimal(local!secondDate - local!firstDate)
        )
      )
    )