Book Contents

Book Index

Next Topic

Home

Date/Time Expressions

Vertica uses an internal heuristic parser for all date/time input support. Dates and times are input as strings, and are broken up into distinct fields with a preliminary determination of what kind of information may be in the field. Each field is interpreted and either assigned a numeric value, ignored, or rejected. The parser contains internal lookup tables for all textual fields, including months, days of the week, and time zones.

The date/time type inputs are decoded using the following procedure.

Tip: Gregorian years AD 1-99 can be entered by using 4 digits with leading zeros (e.g., 0099 is AD 99).

Month Day Year Ordering

For some formats, ordering of month, day, and year in date input is ambiguous and there is support for specifying the expected ordering of these fields. See Date/Time Run-Time Parameters for information about output styles such as POSTGRES.

Special Date/Time Values

Vertica supports several special date/time values for convenience, as shown below. All of these values need to be written in single quotes when used as constants in SQL statements.

The values INFINITY and -INFINITY are specially represented inside the system and are displayed the same way. The others are simply notational shorthands that are converted to ordinary date/time values when read. (In particular, NOW and related strings are converted to a specific time value as soon as they are read.)  

String

Valid Data Types

Description

epoch

DATE, TIMESTAMP

1970-01-01 00:00:00+00 (UNIX SYSTEM TIME ZERO)

INFINITY

TIMESTAMP

Later than all other time stamps

-INFINITY

TIMESTAMP

Earlier than all other time stamps

NOW

DATE, TIME, TIMESTAMP

Current transaction's start time

NOW is not the same as the NOW function.

TODAY

DATE, TIMESTAMP

Midnight today

TOMORROW

DATE, TIMESTAMP

Midnight tomorrow

YESTERDAY

DATE, TIMESTAMP

Midnight yesterday

ALLBALLS

TIME

00:00:00.00 UTC

The following SQL-compatible functions can also be used to obtain the current time value for the corresponding data type:

CURRENT_DATE

CURRENT_TIME

CURRENT_TIMESTAMP

LOCALTIME

LOCALTIMESTAMP

The latter four accept an optional precision specification. (See Date/Time Functions.) Note however that these are SQL functions and are not recognized as data input strings.