Page 1 of 1

datetime conversion

Posted: Fri Mar 09, 2012 12:18 am
by jauson
Hi,

Currently im developing a payroll system now, but im getting a hard time how to calculate datetime from our attendance sheet (biometrics).. I do have connection to import our existing software which is our biometrics going to php mysql database. my problem is I do not have an idea how to calculate their attendance.

example

ID DEPARTMENT NAME EMPLOYEEID DATE/TIME
1 IT JON 100011 2012-04-02 06:00:00 aM
2 IT JON 100011 2012-04-02 06:00:00 PM


how do i manage their attendance or compute DATETIME field to get exactly salaries,


any ideas?

REGARDS ALL,

Re: datetime conversion

Posted: Fri Mar 09, 2012 2:08 pm
by requinix
You want... the number of days since the date? Or what?

Re: datetime conversion

Posted: Sun Mar 11, 2012 7:28 pm
by jauson
I want to calculate datetime to hours or days. for example
2012-04-02 06:00:00 aM
2012-04-02 06:00:00 PM
Result 1 days and/or 12 hours,

Re: datetime conversion

Posted: Mon Mar 12, 2012 5:34 am
by requinix
Here is a good place to look for a MySQL answer. I see two functions in there that will do it.

For a PHP answer it depends whether you have PHP 5.3 or not.

Re: datetime conversion

Posted: Mon Mar 12, 2012 7:43 pm
by jauson
what is that functions?

Re: datetime conversion

Posted: Mon Mar 12, 2012 10:19 pm
by requinix
DATEDIFF() and TIMEDIFF(). One for the number of days, the other for the number of hours.

Re: datetime conversion

Posted: Mon Mar 12, 2012 11:29 pm
by litebearer
@ requinix - I can see how timediff would work with the datetime in and datetime out in the same table row; however, OP seems to have times in and times out in different rows, Could you show example query how one could use that mysql function given the way the OP's data is setup?

OR would OP need to 'grab' data from each row as timestamp then subtract the two?