MySQL Time() Function Example

MySQL Time() Function Example

MySQL time() function; In this tutorial, we would love to share with you MySQL time() functions with the help of 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

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, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL 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 *