
- 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
How to use together the date and time format characters in MySQL DATE_FORMAT() function?
We can use both the format characters together in DATE_FORMAT() function. The following example will clarify this −
mysql> SELECT DATE_FORMAT(NOW(), 'The time is %a %h:%i:%s:%f %p'); +-----------------------------------------------------+ | DATE_FORMAT(NOW(), 'The time is %a %h:%i:%s:%f %p') | +-----------------------------------------------------+ | The time is Sun 06:35:06:000000 AM | +-----------------------------------------------------+ 1 row in set (0.00 sec)
Above query is using date format character ‘%a’ along with other time format characters.
Following is another example in which both format characters are used together −
mysql> SELECT DATE_FORMAT(NOW(), 'The date & time is %a %D %M %Y %h:%i:%s:%f %p'); +---------------------------------------------------------------------+ | DATE_FORMAT(NOW(), 'The date & time is %a %D %M %Y %h:%i:%s:%f %p') | +---------------------------------------------------------------------+ | The date & time is Sun 29th October 2017 06:37:17:000000 AM | +---------------------------------------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- What are different date format characters used by MySQL DATE_FORMAT() function?
- What are the different time format characters used by MySQL DATE_FORMAT() function?
- How to change date format with DATE_FORMAT() in MySQL?
- Format date with DATE_FORMAT() and STR_TO_DATE() in MySQL
- How can I use TIME_FORMAT() function to offload time/date values in MySQL?
- How to format date and time in android?
- Format Date and Time in Perl
- How to change date and time format in Android sqlite?
- How to update the date format in MySQL?
- How to change date time format in HTML5?
- How to print date and time in specific format using JSP?
- MySQL query to return the entire date and time based on a string and format
- How to convert Python date format to 10-digit date format for mysql?
- How to convert a date format in MySQL?
- How to convert US date format to MySQL format in INSERT query?

Advertisements