Nel tutorial di oggi vedremo come selezionare un tempo relativo in una query MySQL.
Nell'esempio specifico, vi mostreremo come selezionare tutti gli utenti che sono stati aggiornati in un intervallo di tempo di 24 ore e in un altro esempio invece gli utenti aggiornati in un intervallo di 2 giorni.
# 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 );



Leave Your Response