
- 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 we offload the time/date handling in MySQL?
We can offload the time/date handling to MySQL with the help of DATE_FORMAT() function. The date and time would be offloaded on the basis of format units passed as arguments to the function.
For example, when we pass the date format units as arguments to MySQL DATE_FORMAT() function then MySQL offloaded only the date as follows −
mysql> Select DATE_FORMAT("2017-10-22 13:03:45", "%Y %M %D")AS 'OFFLOADED DATE'; +-------------------+ | OFFLOADED DATE | +-------------------+ | 2017 October 22nd | +-------------------+ 1 row in set (0.00 sec)
Whereas, when we pass the time format units as arguments to MySQL DATE_FORMAT() function then MySQL offloaded only the time as follows −
mysql> Select DATE_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)
- Related Articles
- How can I use TIME_FORMAT() function to offload time/date values in MySQL?
- In MySQL, how can we declare a handler while handling errors?
- How can we calculate the Date in MySQL using functions?
- How can we do date and time math in Python?
- How can we add a time interval to date stored in a column of MySQL table?
- How can we obtain the part of a date in MySQL?
- How can we insert current date and time automatically on inserting values in other columns in MySQL?
- How to set default date time as system date time in MySQL?
- How can we extract the Year and Month from a date in MySQL?
- How can we calculate the difference between two time values in MySQL?
- In MySQL, how can we represent the time value as an integer?
- In MySQL, how can we display the date in other format specified by the user?
- In MySQL, how can we display time in other format specified by the user?
- How can we insert current date automatically in a column of MySQL table?
- How can we fetch month and day from a given date in MySQL?

Advertisements