Jump to content

need help in concatenation


newphpcoder

Recommended Posts

Hi..

 

I need help in concatenation.

 

here is my code:

 

SELECT (SUM(TIMESTAMPDIFF(DAY, chemicalweighing_dateEntry, NOW()))), (SUM(TIMESTAMPDIFF(HOUR, chemicalweighing_dateEntry, NOW()))) - (SUM(TIMESTAMPDIFF(DAY,chemicalweighing_dateEntry, NOW())) * 24) AS age_day FROM kanban_data;

 

the output of this is:

 

57      204

they are separated in between two columns.

 

I want to combine them in one column like this:

 

57 day(s) 204 hr(s) ago

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/259916-need-help-in-concatenation/
Share on other sites

like this?

SELECT 
CONCAT(
  (SUM(TIMESTAMPDIFF(DAY, chemicalweighing_dateEntry, NOW()))), 
  'day(s) ', 
  ((SUM(TIMESTAMPDIFF(HOUR, chemicalweighing_dateEntry, NOW()))) - (SUM(TIMESTAMPDIFF(DAY,chemicalweighing_dateEntry, NOW())) * 24)),
  'hr(s) ago'
)AS age_day 
FROM 
kanban_data;

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.