
- 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 can I use TIME_FORMAT() function to offload time/date values in MySQL?
TIME_FORMAT() function can be used in a similar fashion as DATE_FORMAT() function but it can only be used for offloading time values. MySQL returns a NULL value if TIME_FORMAT() function is used for offloading date values.
For example, when we pass the time format units as arguments to MySQL TIME_FORMAT() function then MySQL offloaded only the time as follows −
mysql> Select TIME_FORMAT("2017-10-22 13:03:45", "%h %i %s %p")AS 'OFFLOADED TIME'; +----------------+ | OFFLOADED TIME | +----------------+ | 01 03 45 PM | +----------------+ 1 row in set (0.00 sec)
Whereas, when we pass the date format units as arguments to MySQL TIME_FORMAT() function then MySQL returns NULL as follows −
mysql> Select TIME_FORMAT("2017-10-22 13:03:45", "%Y %M %D") AS 'OFFLOADED DATE'; +----------------+ | OFFLOADED DATE | +----------------+ | NULL | +----------------+ 1 row in set (0.00 sec)
- Related Articles
- How can we offload the time/date handling in MySQL?
- How to use together the date and time format characters in MySQL DATE_FORMAT() function?
- How to change date time format in HTML5?
- How to format date and time in android?
- In MySQL, how can I insert date and time automatically while inserting NULL values to the other columns?
- How to set default date time as system date time in MySQL?
- Format Date and Time in Perl
- How to change date and time format in Android sqlite?
- How to use date time picker in Android?
- How can I use any character, at the place of space, in MySQL TIMESTAMP to distinguish between date and time parts?
- Java Program to format date time with Join
- How can I get the current time and date in Kotlin?
- How can I get time and date since epoch in JavaScript?
- How to print date and time in specific format using JSP?
- How to insert current date/time in MySQL?

Advertisements