CURTIME() Function Examples – MySQL

CURTIME() Function Examples – MySQL

Here, you will learn how to use MySQL CURTIME() function with various examples. When you want to get the current time in MySQL queries that time you can use the easily uses the CURTIME().

MySQL CURTIME() Function

Using the MySQL CURTIME function is get the current time.

In other words, the CURTIME function is used to return the current time. MySQL curtime () is equivalent to current_time().

Note:

This function is a synonym for CURTIME () that gets the current time, so you can choose which function you want to use.

Both functions return the current time as values ​​in HH: MM: SS ‘or HHMMSS format, depending on whether you want to the function is used in a string or numerical context.

Syntax

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

Let’s take the first example of CURTIME() function of MySQL is below:

SELECT CURTIME;

Output-1

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

Example-2

Now we take next example of CURTIME() with CURRENT_TIME() function, see the example below:

 SELECT 
 CURTIME,
 CURRENT_TIME(),
 CURTIME();

Result:

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

Example-3

Let’s take another example with the MySQL database. We will fetch employees’ data from database table employees who have start_time greater than the current time.

  SELECT * 
  FROM employees 
  WHERE  start_time > CURTIME()

Example-4

We take next example of CURTIME() using numeric context:

SELECT CURTIME + 0;

Output-4

+------------------+
| CURTIME + 0      |
+------------------+
|           100425 |
+------------------+

In the above example, we have added zero to the time.

Conclusion

Here, you have learned how to use MySQL CURTIME() 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. MAKETIME() Function Examples – MySQL
  11. Localtime() 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.

Leave a Reply

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