CURRENT_DATE()

Documentation

VoltDB Home » Documentation » Using VoltDB

CURRENT_DATE()

CURRENT_DATE() — Returns the current date as a date value.

Synopsis

CURRENT_DATE()

CURRENT_DATE

Description

The CURRENT_DATE() function returns the current date as a VoltDB DATE. The value of the date is determined when the query or stored procedure is invoked. Since there are no arguments to the function, the parentheses following the function name are optional.

Several important aspects of how the CURRENT_DATE() function operates are:

  • The value returned is guaranteed to be identical for all partitions that execute the query.

  • During command logging, the returned value is stored as part of the log, so when the command log is replayed, the same value is used during the replay of the query.

  • Similarly, for database replication (DR) the value returned is passed and reused by the replica database when replaying the query.

  • You can specify CURRENT_DATE() as a default value in the CREATE TABLE statement when defining the schema of a VoltDB database.

  • The CURRENT_DATE() function cannot be used in the CREATE INDEX or CREATE VIEW statements.

Example

The following example uses CURRENT_DATE() and DATEADD() in the WHERE clause to select customers who are 21 years old or older:

SELECT * FROM customers WHERE DATEADD(YEAR,21,customers.birthday) <= CURRENT_DATE;