MySQL CURTIME() Function

MySQL CURTIME() function; In this tutorial, i am going to show you MySQL CURTIME() function with the help of examples.

MySQL CURTIME() Function

CURTIME() function in MySQL is used to check the current time. It returns the current time as a value in ‘hh:mm:ss’ or ‘hhmmss’ format, depending on whether the function is used in a string or numeric context.

Syntax of MySQL CURTIME() Function

The CURTIME() function syntax is:

CURTIME
=================OR================
CURTIME([optional])

The (optional)  an argument can be used to provide the fractional seconds precision. If provided, the return value will include fractional seconds up to the number provided. You can specify a optionalvalue between 0 and 6.

Example 1 – MySQL CURTIME() Function

Let’s take the first example of CURTIME() function of MySQL; as follows:

SELECT CURTIME;

Output-1

+--------------+
| CURTIME      |
+--------------+
| 11:02:42     |
+--------------+

Example 2 – MySQL CURTIME() Function

Let’s take an second example using CURTIME() with CURRENT_TIME() function; as follows:

 SELECT 
 CURTIME,
 CURRENT_TIME(),
 CURTIME();

Output-2

+--------------+----------------+-----------+
| CURTIME      |CURRENT_TIME () | CURTIME() |
+--------------+----------------+-----------+
| 11:05:06     | 11:05:06       | 11:05:06  |
+--------------+----------------+-----------+

Example 3 – MySQL CURTIME() Function

To fetch employees’ data from database table employees who have start_time greater than the current time; as follows:

  SELECT * 
  FROM employees 
  WHERE  start_time > CURTIME()

Conclusion

MySQL CURTIME() Function tutorial, you have learned how to use MySQL CURTIME() function with various examples.

Be First to Comment

Leave a Reply

Your email address will not be published.