0
code   | user_id   | register_date | time_difference
-------+-----------+---------------+----------------
AiK4JJ | kcy2000ok | 2012-01-31    | 17:25:41
unBG1D | gktoql    | 2012-01-31    | 17:25:35
vzqeWU | gktoql    | 2012-01-31    | 17:25:32
vvkOSd | gktoql    | 2012-01-31    | 17:25:32
uwhbGt | ppsh      | 2012-01-31    | 17:25:28
unBG1D | judyssi   | 2012-01-31    | 17:25:27
vvkOSd | judyssi   | 2012-01-31    | 17:25:24

I wanna calculate time difference in seconds between recent date and previous date.

Can you help me to build MySql query?

Taz
  • 3,718
  • 2
  • 37
  • 59
jakedyson
  • 23
  • 1
  • 6
  • 2
    This question has been answered ad nauseum - please check the "Related" column to the right of your screen. – Chris Laplante Feb 05 '12 at 20:03
  • possible duplicate of [Difference between two dates in MySQL](http://stackoverflow.com/questions/4759248/difference-between-two-dates-in-mysql) – Shiplu Mokaddim Feb 05 '12 at 20:11

1 Answers1

0
SELECT 
   UNIX_TIMESTAMP(`recent_date`)
   -
   UNIX_TIMESTAMP(`previous_date`)
AS
   `time difference`;
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187