website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Getting Started
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
Docs powered by archbee 

CURRENT_TIMESTAMP

9min

This article will assist you in how to use the CURRENT_TIMESTAMP() function to return the current timestamp.

Overview

The CURRENT_TIMESTAMP() returns the current timestamp value representing the date and time the query was executed.

ℹ️ Note that the time returned by this function is the time when the query was executed.

Syntax

Syntax
|
CURRENT_TIMESTAMP(precision)


The precision is used to set the number of digits in the fractional seconds precision in the second field.

If you omit the precision, the CURRENT_TIMESTAMP() function will return a current timestamp that includes the complete fractional seconds precision.

⚠️ The maximum precision value that you can input is 6.

Examples

#Case 1: Current timestamp

The following example shows how to get the current date and time with a CURRENT_TIMESTAMP()function:

Select current_timestamp
|
SELECT CURRENT_TIMESTAMP AS "Current Time";


The final result will display the current date and time in your timezone:

Output
|
+-----------------------------+
| Current Time                |
+-----------------------------+
| 2022-08-31 16:56:06.464016  |
+-----------------------------+


#Case 2: Current timestamp with precision

Let’s assume we want to get the current timestamp but with a 2-fractional seconds precision:

Select current_timestamp
|
SELECT CURRENT_TIMESTAMP(2);


The function will return the current date and time with 2 digits after seconds:

Output
|
+-------------------------+
| current_timestamp       |
+-------------------------+
| 2022-08-31 17:15:22.16  |
+-------------------------+




Updated 11 May 2023
Did this page help you?
Yes
No
PREVIOUS
Timestamp Functions
NEXT
FORMAT_TIMESTAMP
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Syntax
Examples
#Case 1: Current timestamp
#Case 2: Current timestamp with precision

Dedicated to data analytics that provides 10x faster execution of analytical queries than current state of the art solutions. We are launching SOON! Join the waiting list for more info.




©2022 Oxla