Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Working hours Ageing

shahnawaz_khan
8 - Asteroid

Hi,

 

I am trying to pull the ageing between one date & time to another with below details.

 

1. if 9:30am to 7pm is the working hours rest we can consider.

2. Anything between 7pm to 9:30am Ageing will become 0:00:00

3.Sunday is non working day, so anything between Saturday 7pm to Monday 9:30am will also be 0:00:00

 

Sample : 

 

Created OnClose DateActual AgeingAgeing in total Hours (this is what I want)
01-01-2025 09:3404-01-2025 19:0581:30:5337:55:53
01-01-2025 13:2405-01-2025 18:29101:04:2637:29:20

 

 

 

1 REPLY 1
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

Hi @shahnawaz_khan ,

 

I tried to follow your logic and got the following results, which is slightly different from your expected result.

RecordIDCreated OnClose DatetotalHours
12025-01-01 09:34:002025-01-04 19:05:0037:56:00
22025-01-01 13:24:002025-01-05 18:29:0034:06:00

 

As 2025-01-05 is Sunday, the end time is "2025-01-04 19:00:00" for both rows, while the start time is 3+ hours late for the 2nd row.

So I guess my result is correct.

Please let me know if you find any issues here. I hope this helps.

 

Workflow

workflow.png

Generate Rows

Initialization Expression: Left([Created On], 10)

Condition Expression: [date] <= Left([Close Date], 10)

Loop Expression: DateTimeAdd([date], 1, "day")

 

Formula #1

[isSunday] = DateTimeFormat([date],"%a") = "Sun"

For [secondsInRange], the expression is long, but the idea is;

  - if the date is Sunday, set 0

  - if the date is start date or end date, adjust the time

  - otherwise set seconds from 9:30 to 19:00

 

Formula #2

[hh] = FLOOR([secondsInRange] / 3600)

[mm] = FLOOR([secondsInRange] / 60) - [hh] * 60

[ss] = [secondsInRange] - [hh] * 3600 - [mm] * 60

[totalHours] = ToString([hh]) + ":" + PadLeft(ToString([mm]), 2, "0") + ":" + PadLeft(ToString([ss]), 2, "0")

Labels
Top Solution Authors