1

Here is my initial code :

SELECT order_logs.order_logs_created, DATEDIFF(HOUR ,NOW(),order_logs.order_logs_created) FROM order_logs

And I gave an error :

#1582 - Incorrect parameter count in the call to native function 'DATEDIFF'

Then , I searched about MariaDB's DATEDIFF and I saw this , I figured out that I can use DATEDIFF with two parameters so I remove HOUR :

SELECT order_logs.order_logs_created, DATEDIFF(NOW(),order_logs.order_logs_created) FROM order_logs

I need time difference in hours , Actually it gives me in days. Any suggestion?

Community
  • 1
  • 1
Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81

2 Answers2

3

You can use TIMESTAMPDIFF for this:

SELECT 
    order_logs.order_logs_created,
    TIMESTAMPDIFF(HOUR,
        order_logs.order_logs_created,
        NOW())
FROM
    order_logs
Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
  • I've already searched and reached my answer . But Thank you for your answer anyway. The essential difference between your answer any my own is position of now and created. – Farzan Najipour Jan 29 '17 at 06:38
0

Use TIMESTAMPDIFF:

SELECT order_logs.order_logs_created, TIMESTAMPDIFF(HOUR ,order_logs.order_logs_created , NOW()) FROM order_logs
Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81