What will be query to check time difference in seconds?

Discussion in 'MySQL' started by Om ji Kesharwani, Oct 25, 2010.

  1. #1
    I have table with column name status which store the time in seconds like 1288072079
    I want to calculate the diffrence between current time and the stored time if the diffrence will be less than 20 minutes means 1200 seconds it should return the effected rows to show the online status.
     
    Om ji Kesharwani, Oct 25, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Use the function UNIX_TIMESTAMP().

    Should be something like:

    SELECT some_columns, (UNIX_TIMESTAMP() - timestamp_column) AS seconds_difference FROM my_table WHERE seconds_difference < 1200;
     
    jestep, Oct 25, 2010 IP
  3. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have done it by own.
    Thanks jestep.
     
    Om ji Kesharwani, Oct 26, 2010 IP