difference between two pair of date and time

These date and time come from MySQL database.
Here is the table of my database. This is where I draw out the information.

[code]-- phpMyAdmin SQL Dump
– version 4.0.10.14
http://www.phpmyadmin.net

– Host: localhost:3306
– Generation Time: Oct 30, 2016 at 06:33 PM
– Server version: 10.0.27-MariaDB-cll-lve
– PHP Version: 5.4.31

SET SQL_MODE = “NO_AUTO_VALUE_ON_ZERO”;
SET time_zone = “+00:00”;


– Database: lnkx10bz_cis



– Table structure for table tact_time

CREATE TABLE IF NOT EXISTS tact_time (
id int(11) NOT NULL AUTO_INCREMENT,
lot_id int(10) NOT NULL,
sub_id int(11) NOT NULL,
proc_type int(11) NOT NULL,
start_time datetime NOT NULL,
end_time datetime NOT NULL,
operator_id int(11) NOT NULL,
input_qty int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
[/code]

From this databasse I get the start_time and end_time difference.
From another database with the same structure I get the start_time and end_time difference.

From this database I will deduct the answer with the another database difference.
Tota.diff = this.db.diff - another.db.diff

After deducting, I need to add all differences on a single variable then echo it to show the total time spent.

accum.variable += total.diff

If there are any unclear please advise. Sorry for my bad English. Thank you.

Another database or another table? Either way, why do you have two with the same structure? Its starting to seem to me your DB (s) design is wrong. Until that is right everything you do with it will not be right.

A brief summary of the overall task at hand would be helpful. And I don’t mean a summary of how you think it needs to be done.

Post the Schema of all the tables/databases involved.

I have been trying, and have asked, what the end goal is. Doing math on multiple tables values will screw you up. I am not sure if you are after an average, a delta, or what!

Until OP answer the basic question, it is pointless to try to help him. I believe we are looking at an X Y problem.

[member=46186]Kevin Rubio[/member] I have read your signature XY Problem and it seems it is an XY problem I am very sorry about. it. My first question or subject “difference between two pair of date and time” already solve by [member=72272]astonecipher[/member] last October 27, 2016, 07:43:49 pm.

I should have been tried to make another post for another question.

Sponsor our Newsletter | Privacy Policy | Terms of Service