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

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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