[Tfug] Representing Periods of Time In MySQL?

Paul Lemmons paul at lemmons.name
Mon Jan 14 15:26:46 MST 2008


-------- Original Message  --------
Subject: [Tfug] Representing Periods of Time In MySQL?
From: "Christopher Robbins" <robbinsc at gmail.com>
To: "Tucson Free Unix Group" <tfug at tfug.org>
Date: 01/14/2008 03:15 PM
> I've been doing some database work for awhile now,
> but I always wondered - is there any "good" or "best" way
> to represent periods of time in MySQL?
>
> I've used a start time (TIME) and an end time (TIME) to do
> so, but I'm beginning to wonder if there's an easier and better
> way?
>
> Thoughts/input are greatly appreciated...
>
>     - Chris
>
>   
It depends almost completely on how your application uses times. 
Generally speaking, you choose database formats to simplify your coding. 
If all you are doing is displaying a start and stop time the way you are 
doing it is probably the best way. If you are going to display 
information like duration (i.e. 1/14/2008 at 3:25pm for 4 hours) then 
storing a start time with a length of time may be more appropriate. If 
you are only dealing with durations then I would not use the Time data 
format at all.

MySql makes the math of working with dates and times so easy, though a 
fairly strong argument could be made for just simply storying start and 
stop times and figuring out duration.

I think the "best" way to do it is the way that you like to do it the 
"best" and works :)

-- 
Sometimes I wonder.  Were our faith able to stand upright and look around, would it be looking down at the mustard seed or standing in awe of the height and breadth of it.





More information about the tfug mailing list