
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to get the previous day with MySQL CURDATE()?
Let us first get the current date using CURDATE(). The current date is as follows −
mysql> select CURDATE(); +------------+ | CURDATE() | +------------+ | 2019-06-09 | +------------+ 1 row in set (0.00 sec)
Let us first create a table −
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate date -> ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command. While inserting, we have used date_sub to get the previous day −
mysql> insert into DemoTable(ShippingDate) values(date_sub(CURDATE(), interval 1 day)); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----+--------------+ | Id | ShippingDate | +----+--------------+ | 1 | 2019-06-08 | +----+--------------+ 1 row in set (0.00 sec)
- Related Articles
- How to get last day of the previous month in MySQL?
- How to get the first day of the previous month in MySQL?
- Get all MySQL records from the previous day (yesterday)?
- How to use CONTAINS() with CURDATE in MySQL?
- How to get the last business day of previous month based on today in Excel?
- C# program to display the previous day
- How to get day name from timestamp in MySQL?
- How to get the first day of next month in MySQL?
- How to get last day of the current month in MySQL?
- How to get last day of the next month in MySQL?
- How can I use INTERVAL keyword with MySQL NOW() and CURDATE() functions?
- How to get the first day of the current month in MySQL?
- CURDATE () vs NOW() in MySQL
- How MySQL behaves when we use INTERVAL of time unit with CURDATE() function?
- Java Program to display previous day from GregorianCalender

Advertisements