Great MySQL Date Functions to Know

You will love this blog because date functions and formatting differ dramatically between databases, but I have covered that with brilliant examples and clear and concise explanations below.
All of these examples have come from my books and training classes. Please do me a favor and tell your training coordinator that you know the best technical trainer in the world. Ask them to hire me to train at your company, either on-site or with a virtual class. They can see our classes, outlines, and a sample of my teaching at this link on our website.
https://coffingdw.com/education/
Below the video are great date functions on MySQL. However, you can first witness a two-minute video that joins a MySQL table with tables from Databricks, Snowflake, Redshift, Google BiqQuery, Synapse, Vertica, Teradata, Oracle, SQL Server, DB2, Yellowbrick, Postgres, Microsoft Access, Excel in a single federated query.
The current_date will return today’s date. Add or subtract a number from the CURRENT_DATE, and you are adding or subtracting days from the date. For example, subtracting from two dates, you get the number of days between the two dates. Notice we performed the cast function to get the dates in a proper format when doing addition or subtraction.

Below are the keywords you can utilize to get the date or timestamp. These are reserved words that the system will deliver to you when requested.

You can use the DATE_ADD function to add or subtract days from a date.

The below examples show how robust the EXTRACT command is at extracting portions of a date, time, or timestamp.

You can use the dayname and monthname to find the day of the week and the month spelled out.

The DATE_FORMAT function formats a date as specified in the argument through specifiers. The percent sign % is required before each format specifier.

Below are several formats of the order_date. These basics will help shape your knowledge of formatting dates.

The DATE_SUB function will subtract a time value (as an interval) from a date.

The DATEDIFF function returns the number of days between two dates or datetimes. This function only calculates the date portion from the expressions.

The DAYNAME function returns the name of the weekday of a date specified in the argument (Sunday, Monday, Tuesday).

The examples below show you how to use day, month, and year intervals.

