TIMEDIFF in MYSQL

585 views Asked by At

TIMEDIFF in MYSQL
I am using Interchange IC (http://interchange.rtfm.info/icdocs/index.html)

[query list=1 sql="SELECT TIMEDIFF(NOW(),'[sql-param time]') as diff"]
my $vardifftime = [sql-param diff];

$vardifftime It is giving output blank.
I want no of hours between current time and datetime type column in mysql database. [sql-param time] stores datetime.

2

There are 2 answers

2
Eugen Rieck On BEST ANSWER
SELECT ROUND((UNIX_TIMESTAMP()-UNIX_TIMESTAMP('[sql-param time]'))/3600);
1
Rahul On

Is [sql-param time] is of datetime cause timediff expects both expression to be of same type. If [sql-param time] is time only then probably you can do like

SELECT TIMEDIFF(TIME(NOW()),'[sql-param time]') as diff