cancel
Showing results for
Did you mean:

# Weekly Challenge

Solve the challenge, share your solution and summit the ranks of our Community!
New content is available in Academy! You may need to clear your browser cache for an optimal viewing experience

## Challenge #68: Elapsed Classroom Times

Director, Customer Enablement

Last week's solution has been posted HERE.

A university analyst has been asked to help with course and classroom resource planning. The university sends course times in military time format. The university analyst wants the fields Military Begin Time and Military End Time to display in standard, 12-hour increments. So, if a course ends at 16:30, he would like it to show as 4:30. He also wants to know what the elapsed time is between the two fields mentioned above. How long is each course? Minutes will be the time unit measured.

Bolide
Spoiler
Meteor
Spoiler
Spoiler

Highlighted
Alteryx Certified Partner

Dear @JoeM,

After seeing the error in my ways, I've read the instructions and completed my homework assignment.

Cheers,
Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Director, Customer Enablement

@MarqueeCrew, part of the challenge is to convert military time to display as standard time :)

Meteoroid

Here is my solution!

Magnetar

My one-tool (plus a Select) solution!

PS. I took the liberty of adding some extra "data validation" to my answers, since there were a few unusual entries... For example: University students have a hard enough time keeping track of class times without worrying whether the start time is listed as after the end time...

Spoiler
Formula Tool:
1. Calculate [Elapsed Time] using DateTimeDiff, DateTimeParse, & PadLeft, including a clause to reverse Begin & End Time if the result was negative hours
2. Calculate [Begin Time] and [End Time] using Trim, DateTimeFormat, ToString, DateTimeParse, & PadLeft (added AM/PM for clarification to the 12-hour time formats)
3. Add a field for [Potential Time Discrepancy] to indicate if there are missing time fields/NULL elapsed times, as well as courses that had a start time that was after the end time.

Mind you, maybe this particular university has night owl courses that start at 4PM and end at 10AM the next day... but I can't imagine those would be very popular courses. I seem to recall being much more interested in studying the beer list at the local tavern during those hours... :)

Alteryx Certified Partner

Here's the route I went down.

Spoiler
I love playing with the date time capabilities in Alteryx but I tend to use the functions available in the formula tool rather than use the date time parse tool. Simply personal preference.

Alteryx Certified Partner

I feel I used too many tools to solve this... I also thought to use a macro I built about duration, but I felt like cheating, so I made it from scratch :)

Good one! :)

Spoiler
Nebula

Very very similar solution to @BenMoss

Spoiler

Ben and I took advantage of the way that alteryx models dates and times internally - by concatenating the start date with a cleaned up version of the time, you can convert the start and end to date-time typed fields (this is cool for step 2 below)
- first difference from Ben - I carried across the TBA (which proved to be incorrect compared to @JoeM output
- second difference.   Sometimes start-date is 'TBA', so I just replace this with '2017-01-01'
One you have the date-time of the start and end-you can then do some simple bits to finish the challenge:
- use dateTimeDiff to work out the minutes
- use dateTimeFormat to get the 12 hr time
Finally - I added in the "Compare2Sets" macro to check that the answers matched