DATE_FORMAT() FUNCTION in MySQL

DATE_FORMAT() FUNCTION
The MySQL DATE_FORMAT function is used to format a date. The various versions of MySQL support the DATE_FORMAT function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0 and MySQL 3.23.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
DATE_FORMAT( date, format_mask )
DATE_FORMAT( date, format_mask )
DATE_FORMAT( date, format_mask )

Parameters:

date: It is used to specify the date to be formatted.
format_mask: It is used to specify the format to be applied to the date.

Example 1:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT DATE_FORMAT ('2019-07-05',
<p><em style="font-size: inherit;"><strong>Output:</strong></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">'Friday'</pre>
<p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p>
<p>The date value has been formatted as specified.</p>
<p><em><strong>Example 2:</strong></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">mysql> SELECT DATE_FORMAT ('2019-07-05',
<p><em style="font-size: inherit;"><strong>Output:</strong></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">'July 05, 2019'</pre>
<p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p>
<p>The date value has been formatted as specified.</p>
<div class="w3sch-c0dddc3abe725179b86dfab6a4872f38 w3sch-after-content" id="w3sch-c0dddc3abe725179b86dfab6a4872f38"></div> </pre>
mysql> SELECT DATE_FORMAT ('2019-07-05', <p><em style="font-size: inherit;"><strong>Output:</strong></em></p> <pre class="EnlighterJSRAW" data-enlighter-language="js">'Friday'</pre> <p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p> <p>The date value has been formatted as specified.</p> <p><em><strong>Example 2:</strong></em></p> <pre class="EnlighterJSRAW" data-enlighter-language="js">mysql> SELECT DATE_FORMAT ('2019-07-05', <p><em style="font-size: inherit;"><strong>Output:</strong></em></p> <pre class="EnlighterJSRAW" data-enlighter-language="js">'July 05, 2019'</pre> <p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p> <p>The date value has been formatted as specified.</p> <div class="w3sch-c0dddc3abe725179b86dfab6a4872f38 w3sch-after-content" id="w3sch-c0dddc3abe725179b86dfab6a4872f38"></div> </pre>
mysql> SELECT DATE_FORMAT ('2019-07-05', 

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
'Friday'
'Friday'
'Friday'

Explanation:

The date value has been formatted as specified.

Example 2:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT DATE_FORMAT ('2019-07-05',
<p><em style="font-size: inherit;"><strong>Output:</strong></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">'July 05, 2019'</pre>
<p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p>
<p>The date value has been formatted as specified.</p>
<div class="w3sch-c0dddc3abe725179b86dfab6a4872f38 w3sch-after-content" id="w3sch-c0dddc3abe725179b86dfab6a4872f38"></div>
mysql> SELECT DATE_FORMAT ('2019-07-05', <p><em style="font-size: inherit;"><strong>Output:</strong></em></p> <pre class="EnlighterJSRAW" data-enlighter-language="js">'July 05, 2019'</pre> <p><em style="font-size: inherit;"><strong>Explanation:</strong></em></p> <p>The date value has been formatted as specified.</p> <div class="w3sch-c0dddc3abe725179b86dfab6a4872f38 w3sch-after-content" id="w3sch-c0dddc3abe725179b86dfab6a4872f38"></div>
mysql> SELECT DATE_FORMAT ('2019-07-05', 

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
'July 05, 2019'
'July 05, 2019'
'July 05, 2019'

Explanation:

The date value has been formatted as specified.