Skip to main content

current_date

1. CURRENT_DATE Function

The CURRENT_DATE function in H2 database is used to retrieve the current date.

2. Syntax

The syntax for the CURRENT_DATE function in H2 database is as follows:

CURRENT_DATE()

Arguments

  • None

Return

  • The CURRENT_DATE function returns the current date as a DATE value.

3. Notes

  • The CURRENT_DATE function does not require any arguments.
  • The returned date does not contain any time information, only the date component.
  • The date is returned in the format 'YYYY-MM-DD'.
  • The CURRENT_DATE function is similar to the GETDATE() function in other databases.

4. Examples

Here are a few examples demonstrating the usage of the CURRENT_DATE function in H2 database:

Example 1 - Retrieving the current date:

SELECT CURRENT_DATE() AS current_date;

Output:

current_date
------------
2022-10-25

Example 2 - Using the current date in a query:

SELECT *
FROM orders
WHERE order_date >= CURRENT_DATE();

Output:

order_id |  order_date   |  customer
---------+---------------+-----------
1 | 2022-10-25 | John
2 | 2022-10-26 | Jane