
- 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
Get day name for the corresponding date in MySQL?
To fetch day name, use DAYNAME() function in MySQL. Let us first create a table −
mysql> create table DemoTable1954 ( ShippingDate date ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1954 values('2019-12-15'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1954 values('2018-04-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1954 values('2019-01-31'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1954 values('2016-10-01'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1954;
This will produce the following output −
+--------------+ | ShippingDate | +--------------+ | 2019-12-15 | | 2018-04-11 | | 2019-01-31 | | 2016-10-01 | +--------------+ 4 rows in set (0.00 sec)
Here is the query to get day name for the corresponding date:
mysql> select dayname(ShippingDate) as Day from DemoTable1954;
This will produce the following output −
+-----------+ | Day | +-----------+ | Sunday | | Wednesday | | Thursday | | Saturday | +-----------+ 4 rows in set (0.00 sec)
- Related Articles
- How to get first day of every corresponding month in MySQL?
- Get the day of week for a particular date in Java
- How to get day name from timestamp in MySQL?
- Get the week number in MySQL for day of week?
- How to display the day name on the basis of Date of Birth records in MySQL?
- Get localized day name in Java
- How to add a day to the date in MySQL?
- How to add 1 day to the date in MySQL?
- Java Program to get display name for Day of Week in different locale
- Create date from day, month, year fields in MySQL?
- Java Program to get full day name
- Get localized short day-in-week name in Java
- Get the Day of the Week from Today's Date in Java
- Get only the date in timestamp in MySQL?
- How to display first day and last day of the month from date records in MySQL?

Advertisements