How can we get difference between two times ?

Hi All,

I am having two times saves in 2 variables 

Eg: 1)  2/5/2023 9:00 AM GMT+05:30.  2)   2/5/2023 8:00 PM GMT+05:30

now my ask is what function we should use in order to get the output like output : 11 hrs or in minuts

and also same for dates 

Thank you 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Generally you can just subtract a datetime value from another, it just takes some effort to meaningfully unpack the result.  Here's my quick attempt at something simple:

    a!localVariables(
      
      local!time1: datetime(2023, 02, 05, 09, 04),  
      local!time2: datetime(2023, 02, 05, 20, 02),
      
      local!difference: local!time2 - local!time1,
      
      a!map(
        days: tointeger(local!difference),
        hours: hour(local!difference),
        minutes: minute(local!difference),
      )
    )

Reply
  • 0
    Certified Lead Developer

    Generally you can just subtract a datetime value from another, it just takes some effort to meaningfully unpack the result.  Here's my quick attempt at something simple:

    a!localVariables(
      
      local!time1: datetime(2023, 02, 05, 09, 04),  
      local!time2: datetime(2023, 02, 05, 20, 02),
      
      local!difference: local!time2 - local!time1,
      
      a!map(
        days: tointeger(local!difference),
        hours: hour(local!difference),
        minutes: minute(local!difference),
      )
    )

Children
No Data