MAKETIME() Function Examples – MySQL

MAKETIME() Function Examples – MySQL

Learn MAKETIME() function uses with examples. We would love to demonstrate to you how to works MySQL maketime() function with its syntax and examples.

MySQL MAKETIME() Function

In MySQL, MAKETIME() function is used to returns the time from the different time parts.

Note:-
In this maketime() function, you can pass three parameters, first is hours, second is minute, and third is seconds. It will return the time value passed on this function.

Syntax

The syntax of MAKETIME() function is:

 MAKETIME(hour,minute,second);

Here we demonstrate :

  • The hour is the hour part.
  • The minute is the minutes part.
  • Second is the seconds part.

Example-1

Let’s take the first basic example of this maketime() function. See the below:

SELECT MAKETIME(10,35,17);

Output-1

+--------------------+
| MAKETIME(10,35,17) |
+--------------------+
| 10:35:17           |
+--------------------+

Example-2

Nextt, we take another example with a fractional part. Let’s see below:

SELECT MAKETIME(10,35,17.123456);

Output-2

+---------------------------+
| MAKETIME(10,35,17.123456) |
+---------------------------+
| 10:35:17.123456           |
+---------------------------+

Example-3

Part of the hour is not limited to 0 to 23 limits. Time can probably represent the time or time elapsed between two incidents.

SELECT MAKETIME(100,35,17);

Output-3

+---------------------+
| MAKETIME(100,35,17) |
+---------------------+
| 100:35:17           |
+---------------------+

Example-4

However, this does not apply to the minute part. It should be within range 0 to 59:

SELECT 
    MAKETIME(10,-1,17),
    MAKETIME(10,60,17);

Output-4

+--------------------+--------------------+
| MAKETIME(10,-1,17) | MAKETIME(10,60,17) |
+--------------------+--------------------+
| NULL               | NULL               |
+--------------------+--------------------+

Example-5

However, this also does not apply to the second part. It should be within range 0 to 59:

SELECT 
    MAKETIME(10,35,-1),
    MAKETIME(10,35,60);

Output-5

+--------------------+--------------------+
| MAKETIME(10,35,-1) | MAKETIME(10,35,60) |
+--------------------+--------------------+
| NULL               | NULL               |
+--------------------+--------------------+

Conclusion

Here, you have learned how to use MySQL MAKETIME() function with various examples.

You may like

  1. TIMESTAMP() Function Examples – MySQL
  2. TIMEDIFF() Function Examples – MySQL
  3. SEC_TO_TIME() Function Examples – MySQL
  4. QUARTER() Function Examples – MySQL
  5. STR_TO_DATE() Function Examples – MySQL
  6. PERIOD_DIFF() Function Examples – MySQL
  7. PERIOD_ADD() Function Examples – MySQL
  8. SECOND() Function Examples – MySQL
  9. MICROSECOND() Function Examples – MySQL
  10. Localtime() Function Examples – MySQL
  11. CURTIME() Function Examples – MySQL
  12. MySQL CURRENT TIMESTAMP Function Examples
  13. MySQL CURRENT TIME Function Examples
  14. ADDTIME() Function Examples – MySQL
  15. MINUTE() Function Examples – MySQL
  16. HOUR() Function Examples – MySQL
  17. NOW() MySQL Function | MySQL
  18. MySQL DATE() And TIME() Functions (List)
  19. TIMESTAMPADD() Function Examples – MySQL
  20. TIMESTAMPDIFF() Function Examples – MySQL

If you have any questions or thoughts to share, use the comment form below to reach us.

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 *