MYSQL- Unable to calculate timediff between to fields and unable to use where clause -


this sql query calculate time difference between datetimesolved , datetimecreated , need result in hours.

$query = "select problem.id, problem.datetimecreated, problem.datetimesolved timediff(hour, problem.datetimesolved, problem.datetimecreated) problem"; 

i have added in clause query:

$query = "select problem.status, problem.id, problem.datetimesolved, problem.datetimecreated, timestampdiff(day, problem.datetimesolved, problem.datetimecreated) problem problem.status = '5' group month(problem.datetimecreated) = month(curdate())"; current format of query works output negative.

i still getting error when try run statement:

you have error in sql syntax;

check manual corresponds mysql server version right syntax

the error message due missing comma before timediff function:

select problem.id, problem.datetimecreated, problem.datetimesolved, timediff(hour, problem.datetimesolved, problem.datetimecreated) 

from problem

then find parameters timediff incorrect. should work:

select problem.id, problem.datetimecreated, problem.datetimesolved, timediff( problem.datetimesolved, problem.datetimecreated) problem 

if need hours:

select problem.id, problem.datetimecreated, problem.datetimesolved, hour(timediff( problem.datetimesolved, problem.datetimecreated)) problem 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -