Previous Topic: The COALESCE FunctionNext Topic: The LOWER Function


The EXTRACT Function

The EXTRACT function returns the month, day, year, hour, minute, or second value from a date, time, or time stamp column value or literal. The syntax is:

EXTRACT(timeunit FROM date-time string/column) 

where timeunit can have one of the following values:

In this example, rows whose last update month is February are selected using the extract function in the WHERE clause:

“SELECT NAME FROM APPLICATIONS WHERE EXTRACT(MONTH FROM UPDATE) = 2”

The APPL1 and APPL2 rows are returned.