
- 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 display coming Sunday's date for all the date records in MySQL?
Let us first create a table −
mysql> create table DemoTable(GetSundayDate date); Query OK, 0 rows affected (0.44 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-08-07'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2018-09-05'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('2019-09-12'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------+ | GetSundayDate | +---------------+ | 2019-08-07 | | 2018-09-05 | | 2019-09-12 | +---------------+ 3 rows in set (0.00 sec)
Following is the query to get this coming Sunday's date for all the dates in the column −
mysql> SELECT date(GetSundayDate + INTERVAL 6 - weekday(GetSundayDate) DAY) AS ComingSundayDate from DemoTable;
This will produce the following output −
+------------------+ | ComingSundayDate | +------------------+ | 2019-08-11 | | 2018-09-09 | | 2019-09-15 | +------------------+ 3 rows in set (0.00 sec)
- Related Articles
- Display all records ignoring the current date record in MySQL
- Display records after a particular date in MySQL
- Fastest way to search for a date from the date records in MySQL
- Display matching repeated date records only once in MySQL
- How to subtract seconds from all the date records in a MySQL column?
- How to change the date in a table with date records with MySQL?
- How to get the difference between date records and the current date in MySQL?
- How to find last date from records with date values in MySQL?
- Condition to check for due date and current date records in MySQL where clause
- MySQL query to subtract date records with week day and display the weekday with records
- How to compare the first date and the last date from a MySQL column with date records?
- How to display the day name on the basis of Date of Birth records in MySQL?
- Display distinct dates in MySQL from a column with date records
- How to display first day and last day of the month from date records in MySQL?
- Comparison of varchar date records from the current date in MySQL

Advertisements