Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

MYSQL query / dates older than 1 week ago (all datetimes in UTC)

SELECT * FROM table WHERE DATEDIFF(NOW(),colname) > 7;

SELECT * FROM tbl WHERE datetime < NOW() - INTERVAL 1 WEEK

If your table stores datetimes in different timezone than what NOW() returns, you can use UTC_TIMESTAMP() instead to get the timestamp in UTC.

Tags:

Datetime

Mysql

Utc

Related

Reasoning behind `from ... import ...` syntax in Python Check if the current user is administrator The model backing the <Database> context has changed since the database was created How can I determine if the column name exist in the ResultSet? Get class name of django model Is there a more elegant way to add nullable ints? Minimizing a Qt application Hibernate query.list() method is returning empty list instead of null value How can I use Delphi to test if a Directory is writeable? How to view the contents of an Android APK file? How to suppress "unused parameter" warnings in C? How to force my C# Winforms program run as administrator on any computer?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy