TRUNCATE()

Documentation

VoltDB Home » Documentation » Using VoltDB

TRUNCATE()

TRUNCATE() — Truncates a VoltDB timestamp to the specified time unit.

Synopsis

TRUNCATE( time-unit, timestamp )

Description

The TRUNCATE() function truncates a timestamp value to the specified time unit. For example, if the timestamp column Apollo has the value July 20, 1969 4:17:40 P.M, then using the function TRUNCATE(hour,apollo) would return the value July 20, 1969 4:00:00 P.M. Allowable time units for truncation include the following:

  • YEAR

  • QUARTER

  • MONTH

  • DAY

  • HOUR

  • MINUTE

  • SECOND

  • MILLISECOND, MILLIS

Example

The following example uses the TRUNCATE function to find records where the timestamp column, incident, falls within a specific day, entered as a POSIX time value.

SELECT incident, description FROM securitylog 
       WHERE TRUNCATE(DAY, incident) = TRUNCATE(DAY,FROM_UNIXTIME(?))
       ORDER BY incident, description;