I want to know how much time has elapsed in seconds from a table field upload_date and now, when the query is executed. After reading some functions of MySQL I tried but wasn’t so lucky.
Is there a way to return the value in hours if it was less than 24 hours, and in days, if it was 100 days or less? Otherwise I will have to code that in PHP.
The date is in CURRENT TIME STAMP format, just to clear that up.
I tried this:
SELECT DATE_SUB(NOW(), upload_date) FROM is_meeting_files
I also tried this, but it gave a difference of 0 seconds:
SELECT DATEDIFF(CURDATE(), upload_date) AS intval FROM is_meeting_files LIMIT 0,5;
You can subtract the unix timestamp values from one another: