Question

I have a WPF app, where one of the fields has a numeric input box for length of a phone call, called ActivityDuration.

Previously this has been saved as an Integer value that respresents minutes. However, the client now wishes to record meetings using the same table, but meetings can last for 4-5 hours so entering 240 minutes doesn't seem very user friendly.

I'm currently considering my options, whether to change ActivityDuration to a time value in SQL 2008 and try to use a time mask input box, or keep it as an integer and present the client with 2 numeric input boxes, one for hours and one for minutes and then do the calculation to save it in SQL Server 2008 as integer minutes.

I'm open to comments and suggestions. One further consideration is that I will need to be able to calculate total time based upon the ActivityDuration so the field DataType should allow it to be summed easy.

Was it helpful?

Solution

The new time datatype only supports 24 hours, so if you need more you'll have to use datetime. So if sum 7 x 4 hour meetings, you'll get "4 hours" back

How the DB stores it is also different to how you present and capture the data.

Why not hh:nn type display and convert in the client and store as datetime?

OTHER TIPS

Track the start and end time, no need to mask out the date, since the duration will just be a calculation off of the two dates. You can even do this in "sessions" such that one meeting can have multiple sessions (i.e. one meeting that spans across lunch, that shouldn't be counted toward the duration...).

The data type, then is either datetime or smalldatetime.

Then to get the "total duration" it's just a query using

Select sum(datediff(mm, startdate, enddate)) from table where meetingID = 1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top