6 messages in com.mysql.lists.mysqlRe: Subtracting 2 times
FromSent OnAttachments
Christopher Molnar10 Aug 2002 06:26 
DL Neil10 Aug 2002 06:36 
Christopher Molnar10 Aug 2002 07:58 
DL Neil10 Aug 2002 08:12 
Alex Pilson10 Aug 2002 10:08 
trog...@math.fsu.edu10 Aug 2002 13:50 
Subject:Re: Subtracting 2 times
From:DL Neil (PHP@DandE.HomeChoice.co.uk)
Date:08/10/2002 08:12:38 AM
List:com.mysql.lists.mysql

Chris,

A pointer is a type of shark! Just like them, this suggestion has sharp teeth too - change the time_in value to 11:45 and see what I mean...

This topic was discussed one week ago ("Time Calculations") - see archives (to save you that, I'll forward you a copy privately (list doesn't like attachments)).

Regards, =dn

Thanks for the quick response. The times are stored in TIME format. If I do the following:

SELECT *, time_out-time_in as job_time from time_sheet;

the job_time column gives me the right time, but is not formatted, for example:

time_in = 11:00 time_out = 13:15

job_time= 21500

Any pointers?

-Chris

On Saturday, August 10, 2002, at 09:36 AM, DL Neil wrote:

Hello Christopher,

I need to ask for some help and I can't find anything in the manuals. I am writing a php based app that as one of it's functions keeps an employee time sheet. The times are stored in a mysql database with 2 columns - time_in and time_out. What I need to do is subtract these to columns to show a job_time (which should be in hh:mm form).

Can anyone give me any suggestions? Or am I better off doing this on the PHP side rather than the mysql side?

My general rule is that when pulling data out of an RDBMS it is best to do as much as possible there, than to transfer data into (say) PHP and post-process it.

Are the times stored as DATETIME/TIME, timestamp, or other format data? The answer will thus vary! Assuming we're not talking about timestamps (trivial exercise) then SEC_TO_TIME() and its counterpart may be of interest. Manual ref: http://www.mysql.com/doc/en/Date_and_time_functions.html

Regards, =dn

To request this thread, e-mail <mysq@lists.mysql.com> To unsubscribe, e-mail <mysql-unsubscribe- molnarc=pand@lists.mysql.com> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

To request this thread, e-mail <mysq@lists.mysql.com> To unsubscribe, e-mail <mysql-unsubscribe-PHPml=dand@lists.mysql.com> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php