CURRENT_TIMESTAMP

CURRENT_TIMESTAMP is a SQL function that retrieves the current date and time set on the system where the database resides. The return type of this function is a TIMESTAMP value.

CURRENT_TIMESTAMP()

Example

SELECT CURRENT_TIMESTAMP;

Output

+---------------------+
| CURRENT_TIMESTAMP |
+---------------------+
| 2022-01-01 10:23:45 |
+---------------------+

Explanation

This example selects the current date and time from the server where the database is running, returned in ‘YYYY-MM-DD HH:MM:SS’ format. In MySQL, CURRENT_TIMESTAMP is a function that retrieves the current date and time.

CURRENT_TIMESTAMP()

Example

SELECT CURRENT_TIMESTAMP;

Output

"2022-02-02 16:20:11.889522+00"

Explanation

The code executes a SQL command to fetch the current timestamp in PostgreSQL. The timestamp includes the date and time up to the microsecond, following the UTC format.

CURRENT_TIMESTAMP

Example

SELECT CURRENT_TIMESTAMP

Output

2022-05-20 16:32:37.933

Explanation

The CURRENT_TIMESTAMP function in SQL Server returns the current timestamp of the system in the format ‘yyyy-mm-dd hh:mi:ss.mmm’.

CURRENT_TIMESTAMP

Example

SELECT CURRENT_TIMESTAMP FROM dual;

Output

26-JAN-22 08.37.28.510000 PM -05:00

Explanation

The CURRENT_TIMESTAMP function in this Oracle SQL code snippet retrieves the current date and time according to the system. This timestamp includes the date, hour, minute, second, and fractional second. It’s augmented with timezone data, indicating the current timezone offset from UTC. The FROM dual clause is a syntax specific to Oracle, which is used when there is no actual table to select from.

CURRENT_TIMESTAMP

Example

SELECT CURRENT_TIMESTAMP;

Output

2022-03-11 14:25:16

Explanation

The CURRENT_TIMESTAMP function in SQLite returns the current date and time as a string in the format YYYY-MM-DD HH:MM:SS.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.