

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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
- Fetch date records comparing with the current date’s day and month in MySQL
- 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 subtract seconds from all the date records in a MySQL column?
- How to compare the first date and the last date from a MySQL column with date records?
- Condition to check for due date and current date records in MySQL where clause
- How to find last date from records with date values in MySQL?
- Comparison of varchar date records from the current date in MySQL
- MySQL query to subtract date records with week day and display the weekday with records
- Format date to display month names with the entire date in MySQL?
- Display distinct dates in MySQL from a column with date records
Advertisements