21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Changed in: <strong>2.1</strong><br />

Internal functions<br />

Description: Extracts and returns an element from a DATE, TIME or TIMESTAMP expression. This function was<br />

already added in InterBase 6, but not documented in the <strong>Language</strong> <strong>Reference</strong> at the time.<br />

Result type: SMALLINT or NUMERIC<br />

Syntax:<br />

EXTRACT ( FROM )<br />

::= YEAR | MONTH | WEEK<br />

| DAY | WEEKDAY | YEARDAY<br />

| HOUR | MINUTE | SECOND | MILLISECOND<br />

::= a DATE, TIME or TIMESTAMP expression<br />

The returned datatypes and possible ranges are shown in the table below. If you try to extract a part that isn't<br />

present in the date/time argument (e.g. SECOND from a DATE or YEAR from a TIME), an error occurs.<br />

Table 12.2. Types and ranges of EXTRACT results<br />

Part Type Range Comment<br />

YEAR SMALLINT 1–9999<br />

MONTH SMALLINT 1–12<br />

WEEK SMALLINT 1–53<br />

DAY SMALLINT 1–31<br />

WEEKDAY SMALLINT 0–6 0 = Sunday<br />

YEARDAY SMALLINT 0–365 0 = January 1<br />

HOUR SMALLINT 0–23<br />

MINUTE SMALLINT 0–59<br />

SECOND NUMERIC(9,4) 0.0000–59.9999 includes millisecond as<br />

fraction<br />

MILLISECOND NUMERIC(9,1) 0.0000–999.9 broken in <strong>2.1</strong>, <strong>2.1</strong>.1<br />

MILLISECOND<br />

Added in: <strong>2.1</strong> (with bug)<br />

Fixed in: <strong>2.1</strong>.2<br />

Description: <strong>Firebird</strong> <strong>2.1</strong> and up support extraction of the millisecond from a TIME or TIMESTAMP. The datatype<br />

returned is NUMERIC(9,1).<br />

138

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!