Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Calculate Business hours & Minutes between two date & Time

Certified Lead Developer

Hi Team,

Looking for a function which can provide hours and minute difference between two date and time considering business calendar.

calworkhours() only provide hours plus it rounds off it to nearest hour.

Looking for below calculation :

Start Time : 20/04/2023 10:00 AM

End Time : 24/04/2023 11:30 AM

Output -  hours : 17 , minutes 30

Calworkhours output - hours : 18

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hi please refer to the below code, without plugin

    a!localVariables(
      local!startdate: datetime(2023, 4, 20, 10, 0, 0),
      local!enddate: datetime(2023, 4, 24, 11, 30, 0),
      local!workday: calworkdays(local!startdate, local!enddate),
      local!HoursofStartdate: hour(local!startdate),
      local!Hoursofenddate: hour(local!enddate),
      local!MinutesofStartdate: minute(local!startdate),
      local!Minutesofenddate: minute(local!enddate),
      local!UpdateHoursofStartdate: if(
        local!HoursofStartdate >= 9,
        local!HoursofStartdate - 9,
        5 - local!HoursofStartdate
      ),
      local!daycount: if(
        local!MinutesofStartdate = 0,
        local!UpdateHoursofStartdate,
        if(
          local!HoursofStartdate >= 9,
          local!UpdateHoursofStartdate + 1,
          local!UpdateHoursofStartdate - 1
        ),
        
      ),
      local!firstdaycount: if(
        local!HoursofStartdate >= 9,
        8 - local!daycount,
        local!daycount
      ),
      local!Mcount: if(
        local!MinutesofStartdate = 0,
        0,
        60 - local!MinutesofStartdate
      ),
      local!lastdayCountcount2: local!Hoursofenddate - 9,
      local!x: local!Minutesofenddate + local!Mcount,
      local!y: if(local!x > 59, mod(local!x, 60), local!x),
      local!total1: if(
        local!x > 59,
        local!lastdayCountcount2 + local!firstdaycount + 1,
        local!lastdayCountcount2 + local!firstdaycount
      ),
      local!total: a!forEach(
        items: enumerate(local!workday - 2) + 1,
        expression: local!total1 + 8 * fv!index
      ),
      local!res: local!total[local!workday - 2] & "Hour " & local!y & "minute",
      local!res
    )

  • 0
    Certified Lead Developer
    in reply to ritikv9840

    Salute to the effort you have put in.

    I don't even have courage to understand this.

Reply Children
No Data