Apps/Gaming

MySQL Quick Tip: Using the DAYOFWEEK Function

Knowing the day of the week for a given date is a common requirement for programs and database administrators who want to obtain data from a database. Fortunately, MySQL has a function known as WEEKDAY this makes collecting this information easy.

The order of the days starts with Sunday (1), Monday (2), Tuesday (3), Wednesday (4), Thursday (5), Friday (6) and ends on Saturday (7).

You can use the … CHOOSE Command with the WEEKDAY Function to query the MySQL database to find out which day of the week a certain date falls. For example, here is a sample MySQL query with WEEKDAY:

SELECT WEEKDAY (‘2021-03-11’);

Running this query would result in the output:

5

November 3, 2021 falls on a Thursday, which is the 5th day of the week.

Read: MySQL INSERT or REPLACE commands

Related posts

Top HTML and CSS Online Courses for Web Developers

TechLifely

MySQL: How to find out the length of text in a column

TechLifely

Data conversion in Go

TechLifely

Leave a Comment