Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL Time Function

by suresh

MySQL Time Function is useful to extract the Time part from the given time or DateTime. In this study, we show you how to use this MySQL Time function to extract the time value from the given expression with an example. The basic syntax of the Time() Function is

TIME(Time or DateTime or expression);

MySQL Time function Example

The following queries help you understand the use of this Time function. Here, we are extracting the Time value from the time expression and different Datetime expressions.

SELECT TIME('10:12:34');

SELECT TIME('2016-05-19 11:14:34');

SELECT TIME('2016-05-19 16:14:39');
MySQL Time Function 1

Time Function Example 2

In this example, we are extracting the Time value from the current date and time returned by the Now, UTC_TIME function, and UTC_TIMESTAMP function.

SELECT NOW(), TIME(NOW());

SELECT UTC_TIME(), TIME(UTC_TIME());

SELECT UTC_TIMESTAMP(), TIME(UTC_TIMESTAMP());
MySQL Time Function 2

In this Date Function example, we are trying to return the Time value from String DateTime format

SELECT NOW(), TIME(NOW() + 10);

SELECT NOW(), TIME(NOW() + 10);

SELECT UTC_TIMESTAMP(), TIME(UTC_TIMESTAMP()+10);
MySQL Time Function 3

Here, we are trying to return the Time value from different DateTime or time formats. Within the last MySQL statement, we used the zeros.

SELECT TIME('2016-05-19 11:14:34.111234');

SELECT TIME('11:14:74.111234');

SELECT TIME('00:00:00');
MySQL Time Function 4

MySQL Time Example 3

In this example, we show how to use this Time function on table data. Here, we are returning the Time value from the Hire Date column.

SELECT EmpID,
FirstName,
LastName,
Occupation,
YearlyIncome,
Sales,
HireDate,
TIME(HireDate)
FROM `MySQL Tutorial`.customer;
MySQL Time Function 5

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy