SQL Date Function EXTRACT()

The EXTRACT() function is a SQL function used to extract a specific component of a date or datetime value, such as the year, month, or day. It takes two arguments: the first argument is the component to extract, and the second argument is the date or datetime value from which the component will be extracted.

The component to extract can be specified as a string, such as "YEAR", "MONTH", "DAY", "HOUR", "MINUTE", or "SECOND". The function returns an integer value representing the specified component.

Here's an example of how to use the EXTRACT() function in a SQL query to extract the year component:

SELECT EXTRACT(YEAR FROM '2022-02-28');
Source:‮www‬.theitroad.com

This query will return the integer value 2022, which is the year component of the date "2022-02-28".

Note that the EXTRACT() function is specific to the database management system you are using, and the syntax and date format it supports may vary slightly depending on the system. Additionally, the EXTRACT() function can be used to extract various components of a date or datetime value, but only one component at a time.