Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Internal functions<br />
::= FROM TO <br />
| , , <br />
::= YEAR | MONTH | DAY<br />
| HOUR | MINUTE | SECOND | MILLISECOND<br />
::= a DATE, TIME or TIMESTAMP expression<br />
• DATE and TIMESTAMP arguments can be combined. No other mixes are allowed.<br />
• With DATE arguments, only YEAR, MONTH and DAY can be used.<br />
• With TIME arguments, only HOUR, MINUTE, SECOND and MILLISECOND can be used.<br />
Computation:<br />
• DATEDIFF doesn't look at any smaller units than the one specified in the first argument. As a result,<br />
- “datediff (year, date '1-Jan-2009', date '31-Dec-2009')” returns 0, but<br />
- “datediff (year, date '31-Dec-2009', date '1-Jan-2010')” returns 1<br />
• It does, however, look at all the bigger units. So:<br />
- “datediff (day, date '26-Jun-1908', date '11-Sep-1973')” returns 23818<br />
• A negative result value indicates that moment2 lies before moment1.<br />
Examples:<br />
datediff (hour from current_timestamp to timestamp '12-Jun-2059 06:00')<br />
datediff (minute from time '0:00' to current_time)<br />
datediff (month, current_date, date '1-1-1900')<br />
datediff (day from current_date to cast(? as date))<br />
Available in: DSQL, PSQL<br />
Added in: <strong>2.1</strong><br />
DECODE()<br />
Description: DECODE is a shortcut for the so-called “simple CASE” construct, in which a given expression is<br />
compared to a number of other expressions until a match is found. The result is determined by the value listed<br />
after the matching expression. If no match is found, the default result is returned, if present. Otherwise, NULL<br />
is returned.<br />
Result type: Varies<br />
Syntax:<br />
DECODE ( ,<br />
, result<br />
[, , result ...]<br />
[, defaultresult] )<br />
136