# EXTRACT

Extracts specified components from a given datetime.

## Syntax

```
EXTRACT (unit FROM dateobj)

```

## Arguments

* dateobj: a valid date, datetime, time, or parsable date string

[DATE\_ADD](https://docs.singlestore.com/db/v9.1/reference/sql-reference/date-and-time-functions/date-add.md)

## Return Type

Integer

## Examples

```sql
SELECT EXTRACT(YEAR_MONTH FROM "2010-04-02 01:23:54");

```

```output

+------------------------------------------------+
| EXTRACT(YEAR_MONTH FROM "2010-04-02 01:23:54") |
+------------------------------------------------+
|                                         201004 |
+------------------------------------------------+

```

```sql
SELECT EXTRACT(MICROSECOND FROM "2010-04-02 01:23:54.567");

```

```output

+-----------------------------------------------------+
| EXTRACT(MICROSECOND FROM "2010-04-02 01:23:54.567") |
+-----------------------------------------------------+
|                                              567000 |
+-----------------------------------------------------+
```

***

Modified at: May 31, 2023

Source: [/db/v9.1/reference/sql-reference/date-and-time-functions/extract/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/date-and-time-functions/extract/)

(An index of the documentation is available at /llms.txt)
