This is an old revision of the document!


Omnidex SQL Function: EXTRACT

Description

The EXTRACT function extracts one or more portions of a date, such as a day, month or year. This is useful for performing logic on portions of a date, such as performing certain actions in certain months. This is also useful for assembling a date string in a specific format.

This function returns a different datatype based on the requested field value.

Syntax

EXTRACT(date_tokens FROM date_column)
date_tokens

Required. One or more tokens representing the portions of date to be extracted, as determined by one or more of the strings shown in the table below.

date_column

Required. A column that is declared as a date_class datatype. The date_class datatypes are any of the date or time oriented datatypes found in the list of Omnidex datatypes.

Example

Example 1: EXTRACT of MONTH

> select birthdate, extract(month from birthdate) mon from individuals;

BIRTHDATE     MON
------------  -----------
  1938-07-14            7
  1957-11-22           11
  1960-07-28            7
  1929-08-22            8
  1933-07-09            7
  1944-08-01            8
  2004-09-14            9

Example 2: $RANDOM with a seed

> select $random(12345) rnd from $omnidex;

RND
-----------
 1255939488

Additional Resources

See also:

###

Example

select status,
extract(mmm FROM orders.order_date)
from orders 
where product_no='PRN4356'

ORDR   JANUARY
ORDR   DECEMBER
CNCL   MARCH
 
Back to top
dev/sql/functions/extract.1280208646.txt.gz ยท Last modified: 2016/06/28 22:38 (external edit)