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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing Time in a database

Status
Not open for further replies.

dhoward007

Programmer
Feb 6, 2002
45
US
I have an application that I need to track time spent on a specific task.. My question is, should I use date time to do this? Later I will need to run totals on the time spent on each task.
 
declare @start datetime
set @start = getdate()
--------
sql statement(task query statement)---
--------
declare @end datetime
set @end = getdate()

select convert(varchar(10),@end-@start,108) as time_consume
 
I guess my question is Should I use the data type date time or should I use the numeric data type to store the time.
 
I think it's better to store as numeric data type.Because at last all you have to manipulate is "/" & "%".

But using datetime.You have to use datediff.And datediff will ceate some other problem.
 
Thanks ClaireHsu

I have decided to store my time as numeric in seconds. I can format it when I report.


Thanks for your help. I believe this will make things much easier this way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top