Re: What is the right datatype to store Hours up to the minute precision?



serge (sergea@xxxxxxxxxxxxxxxxx) writes:
> What would be the best way to store hours/minutes
> based on how we are using Time in the database?
>
> Either I will stick with Integer but store in minutes
> time instead of calculating in seconds and most likely
> update all the SUM(ENTEREDTIME) to
> SUM(CAST(ENTEREDTIME AS BIGINT))

Since you appear to have an application that is working, I would do
as little change as possible.

Storing elapsed time as minutes rather than seconds makes sense if you are
not supporting seconds anyway. Then again, do the potential seconds
cause any menace?

Of course, if you store by minutes you may not need bigint, but that
depends on what that sum(enteredtime) reflects. If you store by minutes,
you need 4085 years for an overflow, which is a lot for a single person. But
if the sum encompasses a workforce of 20000 employeess, it only takes
74 days per person to overflow.

Had we been talking about a new application, I can't say for sure what
I would recommend. All the datatypes have their tradeoffs. But keep in
mind that it's possible to have computed columns, so you could have
both a smalldatetime column and a minutes column if you like.

--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Newbie help
    ... think I can probably get what I need using SQL Server (the ... > To efficiently store and retrieve data for your needs, ... You only store changed values (as ...
    (microsoft.public.sqlserver.programming)
  • Re: meta data & full text search
    ... There are more issues (transaction control, change control, audit of ... storing the files in a SQL Server table's column defined with an IMAGE ... if you store the files ... consistency of the database, indices, backup, restore, etc. ...
    (microsoft.public.sqlserver.fulltext)
  • Re: How to Insert date in sql server database
    ... I am getting input from the HTML form and store it to database using ... (it's VB6 and not ASP, but I believe that they are not too different): ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Access 2000 - Realtime Development - Should i stick with Access97
    ... if I needed to start using SQL Server to store Tables of an Access 97 front ... would this force the need to upgrade. ... > is because you have support clients who are using later versions. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Unicode and long data type
    ... The SQL Server equivalent is a BigInt that ... can store up to 8 bytes of data. ... Hitchhiker's Guide to Visual Studio and SQL Server ... Everything works except for the Unicode data in the ...
    (microsoft.public.dotnet.framework.adonet)