How to Get Day Names in SQL

To get day names from a date column in your database, use the DAYNAME() function. This function takes a single argument, which is the date column you want to get the day names from. For example, if you wanted to get the day names from the date_column column of your database, you would use the following query:

SELECT DAYNAME(date_column) FROM table_name;

Examples

Let's look at a few examples of how this function can be used. Suppose you have a table called orders with the following data:

orders
date_column
2020-01-01
2020-01-02
2020-01-03
2020-01-04

If you wanted to get the day names from this table, you would use the following query:

SELECT DAYNAME(date_column) FROM orders;

This query would return the result Wednesday, Thursday, Friday, Saturday, since those are the day names for the dates in the table.

Additional Info

The DAYNAME() function is supported by most major databases, including MySQL, PostgreSQL, and SQL Server. However, the syntax may vary slightly depending on the database you are using. For more information, check out the documentation for your particular database. 🤓

Want to build your own LLM Apps with AirOps👇👇