Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
waterboy1628
Starting Member
4 Posts |
Posted - 2011-12-05 : 16:47:17
|
| All - I know this topic has been beaten to death in this and other forums, but I'm hoping for a clear definitive answer. I have a database that compiles telephone talk time for various individuals. The data is imported from CSV files that are in the hh:mm:ss format. Once the data enters the table, it appears in the 12/30/1899 12:00:00 AM datetime format. Ideally, I would like all the time formats in my database to be hh:mm:ss or hhhh:mm:ss if we are looking at totals for a long time period (comparing yearly statistics).Since my data is not in seconds already, should converting to seconds be my first step? Or, is there another way, perhaps an ideal time format? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-05 : 20:01:13
|
since your data is actually elapsed time, you should store it in integer in terms of seconds. It will make any computation like sum() or avg() much easier. And when presenting the data you can use convert(varchar(10), time_in_seconds, 108) to format it in HH:MM:SS or do this in your front end application KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-06 : 00:10:45
|
| use time datatype if you want to store timepart alone and you're in sql 2008 or later------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
waterboy1628
Starting Member
4 Posts |
Posted - 2011-12-06 : 10:28:28
|
| Thank you for your input! I think I will end up taking khtan's advice, for I will need to do a lot of calculations to find the Sum, Avg, etc. |
 |
|
|
|
|
|
|
|