On Wednesday, March 30, 2005 09:49, Christopher Vaughan wrote: > I have data in a table listed as > 44:22:22 > 333:33:33 > It stands for hhh:mm:ss
If you convert it to a time field you can use mysql built-in functions to do what you want. You are limited to the range -838:59:59 to 838:59:59 though. http://dev.mysql.com/doc/mysql/en/time.html http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html > I want to break each part of the data into different parts based on > the ':' to separate them. Then I want to take that data and sum it. > I wrote an if statement to parse through this table but I can't get > it to work. I am not sure If my syntax is wrong because I can't find > anything to check against it. > > Here is the syntax: > > IF > (SELECT job_walltime > FROM time > WHERE CHAR_LENGTH( job_walltime ) >=9) > THEN > (SELECT sum( left( job_walltime, '3' ) ) hours, sum(mid( > `job_walltime` , 4, 2 )) , sum( right( job_walltime, '2' ) ) > seconds > FROM `time`) > ELSE > (SELECT sum( left( job_walltime, '3' ) ) hours, sum(mid( > `job_walltime` , 3, 2 ) ), sum( right( job_walltime, '2' ) ) > seconds > FROM `time`) > END > > I know this isn't the only way to do this but this but this is the > first suggestion that comes to mind. Any input would be great. > > Further info MySQL 3.23.58 running on RedHat 9 > > -Chris Vaughan -- Tom Crimmins Interface Specialist Pottawattamie County, Iowa -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]