Home >Database >Mysql Tutorial >How to Add a Day to the MySQL NOW() Function?

How to Add a Day to the MySQL NOW() Function?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2025-01-02 15:41:39525browse

How to Add a Day to the MySQL NOW() Function?

How to Add a Day to NOW() Function in MySQL

MySQL's NOW() function returns the current date and time. In certain scenarios, it may be necessary to modify this timestamp to represent a future date. This article explores how to add one day to the NOW() function in MySQL.

Solution:

To add one day to the NOW() function, you can use the INTERVAL keyword. The syntax is as follows:

NOW() + INTERVAL 1 DAY

This expression will return a timestamp that represents the current date and time plus one day. For example:

SELECT NOW() + INTERVAL 1 DAY;

This query will return a result similar to:

2023-03-09 10:30:15

Note: If you are only interested in the date, not the date and time, you can use CURDATE instead of NOW. The CURDATE() function returns the current date.

Example:

SELECT CURDATE() + INTERVAL 1 DAY;

This query will return the following result:

2023-03-09

The above is the detailed content of How to Add a Day to the MySQL NOW() Function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn