MySQL Time() Function Tutorial

MySQL Time() Function Tutorial

In this MySQL time() function tutorial, we would love to share with you MySQL time() functions with its definition, syntax, parameter, and examples.

MySQL time() Function

Definition:- Time() function is the inbuilt function of MySQL, which is used to select the time part from the given DateTime or time.

Note:- If you can pass wrong DateTime or time and NULL value in this function, returns “00:00:00”.

Syntax

TIME(DateTime/Time)

Parameters of time function

DateTime/Time:- It is a required. To extract the time from the datetime or time.

Example 1 Of Time() Function

Let’s take the first example, In this example, we will pass the DateTime value in time() function and it will extract the time part from the DateTime value:

SELECT TIME("2020-01-04 10:21:15");

The output of the above query is the following:

 10:21:15

Example 2 of time() function

Let’s take the first example, In this example, we will pass the NULL value in time() function and it will extract the time part from the NULL value:

SELECT TIME(NULL);

The output of the above query is the following:

TIME(NULL)

Example 3 – Fractional Seconds

Here we will take the third example, In this third example, we will select/extract time fractional time part of the given DateTime value.

SELECT TIME('2020-01-04 11:14:12.123456');

The output of the above query is the following:

11:14:12.123456

Recommended Tutorial

  1. MySQL Tutorial With Examples
  2. PHP Date and Time functions tutorial
  3. MySQL: DATE() And TIME() Functions Tutorial

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *