Return to Snippet

Revision: 57941
at June 16, 2012 00:56 by Jamie


Initial Code
# Relative Time
DATE_SUB( NOW( ) , INTERVAL 25 HOUR )

# For example:
# Select all users who were updated in the last 25 hours.
SELECT * FROM users
WHERE users.updated > DATE_SUB( NOW( ) , INTERVAL 25 HOUR );

# Select all users who were updated in the last 2 days.
SELECT * FROM users
WHERE users.updated > DATE_SUB( NOW( ) , INTERVAL 2 day );

Initial URL

                                

Initial Description
Retrieves a relative time in a MySQL Query

Initial Title
MySQL Time Ago function

Initial Tags

                                

Initial Language
MySQL