Navigation:  NexusDB Guide > SQL Reference > SQL Functions > Numeric Value Functions >

Extract Expression

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

Extract Expression

button_main button_prev button_next

NexusDB Manual V3 > SQL Reference > SQL Functions > Numeric Value Functions

Syntax

 

<extract expression> ::=

 

 

 

EXTRACT ( <extract field> FROM <extract source> )

<extract field> ::= <primary datetime field>

 

<extract source> ::= <datetime value expression>

 

 

Notes

 

§

The EXTRACT function returns the datetime field specified by <extract field> from the <extract source>.

 

§

If SECOND is specified as extract field, then the data type of the result is DOUBLE PRECISION, else the data type of the result is INTEGER.

 

§

If either of the arguments are null, then the result is null.

 

 

Examples

 

1) The following example extracts the YEAR, MONTH and DAY fields from the orderDate column:

 

      SELECT

orderID,

EXTRACT( YEAR FROM orderDate ) AS "Year",

EXTRACT( MONTH from orderDate ) AS "Month",

EXTRACT( DAY FROM orderDate ) AS "Day",

orderTotal

      FROM orders

 

2) The following example groups order totals by year:

 

      SELECT

"Year",

SUM( orderTotal ) AS "Total Amount"

      FROM

      (

SELECT

EXTRACT( YEAR FROM orderDate ) AS "Year",

orderTotal

FROM orders

      ) AS orders

      GROUP BY "Year"

 

 


Conformance

 

SQL:2003 standard

-

Feature F052 "Intervals and datetime arithmetic"

 

© Nexus Database Systems Pty Ltd.

nexus_logo