is there any datatype for duration

  • Hello all,

     

    I am using SQL Server 2000 and I just wanna store time duration for example stroing how long the reader stays in the library .. I want it in 00:00:00 format or  hour:min:sec ..

    What is the appropriate datatype for it?

    And I don''t think datetime is suitable for it I just want to store the duration only

    And if there is no suitable datatype what is the best solution for it?

     

    Thanks all

  • IMHO Datetime is the correct datatype for it. just because you don't want /need the day information doesn't mean its not right.

    Just store the day as 01/10/1900 and then the time. If you use datetime you have the ability to use all the date oriented functions which will decrease needed code and simplify it.

    Of course there are many ways to handle this issue.

  • I would store the duration as the seconds elapsed and allow the front end to present the data in any format desired, hh:mm:ss in your case.  Also, there may be no need to store the duration if the time entered and time left are also stored.  The duration of the visit is the difference between these 2 times and could be easily calculated at query time using DATEDIFF.

  • I thought about storing the start and end time but I don't want to use that method

    I think the best way as you said is to store the time duration in seconds and present it in the format I need

     

  • Just a word of advice on only storing the duration.  You will be losing valuable data about when the visit occurred if you don't store the start and end times.  It may be important to know when the longest visit times are so you can add more staff or decide to open earlier or close later.  It is best to not throw away data that could be used to make business decisions later.

     

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply