alteryx Community

# Alteryx Designer Desktop Discussions

SOLVED

## calculating the datetime difference including weekend

11 - Bolide

Hi Team,

hope you are well.

((DateTimeDiff([ISSUEDATE],[TIMECREATED],"days")*5 - (ToNumber(DateTimeFormat([TIMECREATED], "%w"))-ToNumber(DateTimeFormat([ISSUEDATE], "%w")))*2) / 7) + IIF(DateTimeFormat([ISSUEDATE], "%w")=="6",-1,0) +
IIF(DateTimeFormat([TIMECREATED], "%w")=="0",-1,0)

Thanks,

Sr

5 REPLIES 5
15 - Aurora

hi @sriniprad08 As it is a matter of logic(not Designer functionality), only who knows the context of data can answer to your question. I mean, it is not us but your colleague😅

By the way, you can rephrase it simpler by using IN operator.

``````(DateTimeDiff([ISSUEDATE],[TIMECREATED],"days")*5-(ToNumber(DateTimeFormat([TIMECREATED], "%w"))-ToNumber(DateTimeFormat([ISSUEDATE], "%w")))*2)/7
+
IIF(DateTimeFormat([ISSUEDATE], "%w")in ("0","6"),-1,0)``````

This expression may be for calculating number of weekdays except for Sunday and Saturday, you said "including weekend" though.

If so, you can do:

1) Create all of days by Generate Row tool
2) Find "Week of Day" for those days by Formula tool

3) Filter out Saturday and Sunday, and count the number of records from T-anchor of Filter tool.

That would give you more readable WF, in my opinion.

11 - Bolide

Great thank you @gawa . Unfortunately that colleague left :)

11 - Bolide

@gawa can you please share the workflow?

thanks,

Sr

11 - Bolide

Hi @gawa

Can you please share the workflow?

Thanks

Sri

15 - Aurora

@sriniprad08 Sorry, I didn't save that WF so I cannot retrieve it., but if you have specific concern/question on how to configure tools, I'd be happy to help you. Please let me know if any.

Labels