Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data type to store work hours

Status
Not open for further replies.

TomasCrossroads

Programmer
Aug 13, 2002
34
BE
Hello,
I think my question is rather stupid, but I was wondering what data structure I use best to store time-based data. I have to store the workhours spent each day for the employess of a company. First only hours were to be stored, so I used an integer value. A day could consist of 7 workhours, 8 workhours, ...
Now they want me to keep an exact time for each day. For example: 8 hours and 23 minutes.
Now what is the best choice as data type?
I could use 2 integer values: 1 for hours and 1 for minutes
Or a real value? For example 1.60 would be 1 hours and 36 minutes then...
Or should I use a smalldatetimevalue?

I have to do a lot of calculations with those data, so it has to be easy to use...

I'm rather new in the business, what's the common practice for this kind of problem?

Thanks

Tomas
 
I would suggest smalldatetime as there are several built in SQL functions to maipulate datetime data. You could use two columns, starttime and endtime for a specific task and have the ability to get to the second detail at a later date if the need arises. The Cast function can be used to display the result of the time math in a format suitable for reporting.
 
Tomas,
It is not a tough one to answer. My be you have a couple of methods to do it.
I would first suggest you use two fields to enter the data.
There is another way, by which you can opt to make the field varchar, and insert a delimiter between the dat and time.
for ex: 7hrs 23 Mins will be stored as 7|23
now, if you are in the vb front end, call split function to store the two values in to an array, and manipulate them.

All the best for you in this project.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top