2 of 2 people found this helpful
Very interesting question. I tried my old tricks using Float but discovered a roadblock: Float("12:30:15") works but Float("1:12:30:15") does not. Obviously it expects a time span less than a day, or more precisely less than 24 hours. You can workaround it with more expressions to pull separate the number of days from the partial day:
CLICK ON IMAGE TO EXPAND
Keep in mind this only works if your input string always contains days, even if its 0. However, this really is a standard 24 hour day, so you will run into inaccuracies during a DST transition where the day may be 23 hours during Spring Forward or 25 hours during Fall Back. This is not due to AF but rather a limitation of days in a time span string.
In short, I pull the day value out and make it an integer with UOM of Day. I then convert the remainder of the string to be a TimeSpan object, which I can then make a floating point number with UOM of seconds. Then I can add the 2 together but I must be on the same UOM when doing that.
Given the DST quirks inherent with your current setup, if at all possible I would recommend passing in the starting and ending time, so that you can skip all the string checks and just produce a time difference. It would be a whole lot simpler and not give erroneous results during DST transitions.
I like your solution better than mine, as you converted everything to proper AF time units. I should have done that... noted for next time.
Thank you Rick! This works perfectly for what I need.
1 of 1 people found this helpful
Hi Jacob, I made an analysis that breaks your time string down into its separate parts and then converts each part into a number, and combines the results at the end.
This is probably too complicated. Your best bet would be to use the ParseTime() function to convert your time string to a time value, then use the Hour(), Minute() and Second() functions to extract those portions and do the math at the end. You'd probably have to extract the day separately like I did above.