cancel
Showing results for
Did you mean:
Announcement | Get certified today - take the Alteryx Designer Core and Advanced exams on-demand now!
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Weekly Challenge
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Unable to display your progress at this time. Please try again a little later, or contact an administrator if you continue to see this error.

## Challenge #68: Elapsed Classroom Times

Sr. Learning Strategy Manager

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

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.
Sr. Learning Strategy Manager

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

Meteoroid

Here is my solution!

Pulsar

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
Aurora

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