ba.saidou (7/31/2014)
The goal here is to calculate a UPH of an activity, the activity is considered picking materials.The issues I am running into is that as long the users are continuously performing the picking without interruption I can calculate their UPH based on the total units picked divided by the hour but when I have a user who only performed a single activity for the hour it throws my numbers off. I believe by converting the time to decimal this will eliminate the issue.
Based on that I am expecting a (8.266666667) Result number.
Thanks,
So what you really want is to look at the time portion. Keep the hours as is and make the minutes a decimal? Seems pretty strange but whatever.
This should do it.
declare @UPH datetime = '2014-07-29 08:16:31.000'
select cast(DATEPART(hour, @UPH) as varchar(2)) + '.' + stuff(cast(DATEPART(minute, @UPH) / 60.0 as varchar(10)), 1, 2, '')
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/