Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #68: Elapsed Classroom Times

JoeM
Alteryx Alumni (Retired)

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.

 

MT.png

alex
11 - Bolide
Spoiler
68a.JPG
chris_fort
7 - Meteor
Spoiler
SpoilerCapture.PNG

 

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

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 restart. Order shall return.
Please Subscribe to my youTube channel.
JoeM
Alteryx Alumni (Retired)

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

JSaumya
6 - Meteoroid

Here is my solution!

NicoleJohnson
ACE Emeritus
ACE Emeritus

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... :)

 

BenMoss
ACE Emeritus
ACE Emeritus

 

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.
68.png



Simona
7 - Meteor

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
Time challenge.PNG
SeanAdams
17 - Castor
17 - Castor

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

Capture.PNG