Jump to content

how to compute the aging time from datetime data's


newphpcoder

Recommended Posts

Hi..

 

I have datetime data in my table kanban_data field chemicalweighing_dateEntry.

sample data of chemicalweighing_dateEntry:

 

2012-03-20 08:12:55

2012-03-20 08:16:44

2012-03-20 08:19:28

2012-03-20 08:20:17

2012-03-20 08:27:52

2012-03-20 08:28:36

2012-03-20 08:29:03

2012-03-20 08:31:47

2012-03-20 08:32:24

2012-03-20 08:35:45

 

I need to get the aging of chemicalweighing_dateEntry.

 

using this formula:

 

Aging time (00:00:00) = now() - SUM of chemicalweighing_dateEntry.

 

 

I don't know what mysql function should I used to get the aging time.

Thank you

 

 

 

 

 

First, I get the elapse time using this code:

 

TIMEDIFF(compounding_DATE_ENTRY,chemicalweighing_DATE_ENTRY) AS elapse1,
           TIMEDIFF(extrusion_DATE_ENTRY,compounding_DATE_ENTRY) AS elapse2,
           TIMEDIFF(forming_DATE_ENTRY,extrusion_DATE_ENTRY) AS elapse3,
           TIMEDIFF(deflashing_DATE_ENTRY,forming_DATE_ENTRY) AS elapse4

 

then I use avg to get the aging per elapse.

 

here is the code:

age_count_wip_chemical_weighing = (SELECT SEC_TO_TIME(time_to_sec(NOW()) - AVG(TIME_TO_SEC(elapse1))) AS age_count_wip_chemical_weighing FROM kanban_data ORDER BY elapse1),
age_count_wip_compounding = (SELECT SEC_TO_TIME(time_to_sec(NOW()) - AVG(TIME_TO_SEC(elapse2))) AS age_count_wip_compounding FROM kanban_data ORDER BY elapse2),
age_count_wip_extrusion = (SELECT SEC_TO_TIME(time_to_sec(NOW()) - AVG(TIME_TO_SEC(elapse3))) AS age_count_wip_extrusion FROM kanban_data ORDER BY elapse3),
age_count_wip_forming = (SELECT SEC_TO_TIME(time_to_sec(NOW()) - AVG(TIME_TO_SEC(elapse4))) AS age_count_wip_forming FROM kanban_data ORDER BY elapse4);

 

Is it right my query to get the aging?

 

Thank you so much

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.