localtime
1. LOCALTIME Function
=======localtime
1. LOCALTIME Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe LOCALTIME function in H2 database is used to retrieve the current system time.
2. Syntax
The syntax for the LOCALTIME function in H2 database is as follows:
LOCALTIME([precision])
Arguments
precision
(optional): Specifies the precision of the time value to be returned. It can be one of the following values:'YEAR'
,'MONTH'
,'DAY'
,'HOUR'
,'MINUTE'
,'SECOND'
,'MILLISECOND'
.
Return
- The LOCALTIME function returns the current system time as a timestamp.
3. Notes
- The LOCALTIME function in H2 database does not require any arguments. If an argument is provided, it specifies the precision of the returned time value.
- The precision argument is optional. If not specified, the default precision is
'SECOND'
. - The returned timestamp is in the format
'YYYY-MM-DD HH:mm:ss.SSS'
. - The LOCALTIME function retrieves the time in the local time zone of the database server.
- Be aware of the time zone differences when working with databases across different regions.
4. Examples
Here are a few examples demonstrating the usage of the LOCALTIME function in H2 database:
Example 1 - Retrieving the current system time:
SELECT LOCALTIME() AS current_time;
Output:
current_time
-------------------
2022-01-01 09:30:45
Example 2 - Retrieving the current system time with different precisions:
SELECT LOCALTIME('HOUR') AS current_hour,
LOCALTIME('MINUTE') AS current_minute,
LOCALTIME('SECOND') AS current_second;
Output:
current_hour | current_minute | current_second
-------------+----------------+----------------
09 | 30 | 45
5. Related Functions
- current_date - Retrieve the current date
- current_timestamp - Retrieve the current timestamp