SQL CURRENT_TIME Function Example
SQL CURRENT_TIME function is used for returning the current time of the database server. The time will be returned either as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).
SQL CURRENT_TIME Function
The CURRENT_TIME() function returns the current time in the database.
The CURRENT_TIME is a standard-SQL function supported by almost all database systems such as DB2, Firebird, MySQL, PostgreSQL, and SQLite.
SQL Server does not support the CURRENT_TIME function; however, you can use the GET_DATE() function to return the current time.
See the following syntax.
See the following example.
SELECT CURRENT_TIME () +1
Adding 1 to this function, it returned the value in numeric form.
Above CURRENT_TIME function applies only to MYSQL.
To use it on the SQL_SERVER getdate () function has to be used.
SELECT CONVERT (TIME, GETDATE ()) AS 'CURRENT_TIME using GETDATE()';
|CURRENT_TIME using GETDATE()|
Oracle does not have a specific function to return the current time. However, you can use the SYSDATE function that returns both date and time and uses the TO_CHAR() function to format the time.
See the following query.
SELECT TO_CHAR(SYSDATE, 'HH24:MI:SS') FROM dual;
In this tutorial, you have learned how to use the SQL CURRENT_TIME function to get the current time of the database server.
The return value does not change during the transaction. Thus, multiple calls to CURRENT_TIME() within the same transaction return the same timestamp.
MySQL CURRENT_TIME() function
In MySQL, the CURRENT_TIME() returns the current time in ‘HH:MM:SS’ format or HHMMSS.uuuuuu format depending on whether numeric or string is used in the function. CURRENT_TIME() and CURRENT_TIME are the synonyms of CURTIME().
If you want to get the current time from the database server, then you can use the CURRENT_TIME() function.
Finally, SQL CURRENT_TIME Function Example is over.