Reputation: 5
i want to show average diff of 2 dates colums as in int data type. i know how to show if thats date column but not now how with int data type.
i tried this but nothing shows:
mysql_query("select AVG(update - date) AS avg_time from qchat_sessions");
Thanks
EDIT:
i used this query now and it shows 153.000
$sss=mysql_query("select AVG(`update` - `date`) AS avg_time from qchat_sessions");
$rows = mysql_fetch_array($sss);
echo $rows[0];
and dates are stored in int data type. now how can i show in time ?
Upvotes: 0
Views: 59
Reputation: 677
You can try this query below:
SELECT AVG(
DATEDIFF(MIN(qchat_sessions.update), posts.date)
)
FROM qchat_sessions
Upvotes: 0
Reputation:
Your issue is most likely that update
and date
are clashing with the similarly named MySQL keywords.
Try quoting them:
SELECT AVG(`update` - `date`) AS avg_time FROM qchat_sessions
If that doesn't help, check the output of mysql_error()
for hints.
Upvotes: 2