localtimestamp
1. LOCALTIMESTAMP Function
=======localtimestamp
1. LOCALTIMESTAMP Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe LOCALTIMESTAMP function in H2 database is used to fetch the current date and time.
2. Syntax
The syntax for the LOCALTIMESTAMP function in H2 database is as follows:
LOCALTIMESTAMP
Arguments
The LOCALTIMESTAMP function does not require any arguments.
Return
- The LOCALTIMESTAMP function returns the current date and time as a TIMESTAMP value.
3. Notes
- The LOCALTIMESTAMP function in H2 database does not require any arguments. It automatically fetches the current date and time.
- The returned value is of the TIMESTAMP data type.
- The timezone used for the current timestamp is the timezone of the H2 database session.
- The LOCALTIMESTAMP function does not change during the execution of a single statement in H2 database.
4. Examples
Here are a few examples demonstrating the usage of the LOCALTIMESTAMP function in H2 database:
Example 1 - Fetching the current timestamp:
SELECT LOCALTIMESTAMP AS current_timestamp;
Output:
current_timestamp
-------------------------
2022-09-01 14:30:45.123456
Example 2 - Using the current timestamp in a query:
SELECT id, name, created_at
FROM users
WHERE created_at >= LOCALTIMESTAMP - INTERVAL '1' DAY;
Output:
id | name | created_at
---+-------+-----------------------------
1 | John | 2022-08-31 09:15:30.987654
2 | Alice | 2022-09-01 11:00:00.123456
5. Related Functions
- current_date - Fetch the current date
- current_time - Fetch the current time
- current_timestamp - Fetch the current timestamp