

# Date parts for date or timestamp functions
<a name="Dateparts_for_datetime_functions"></a>

The following table identifies the date part and time part names and abbreviations that are accepted as arguments to the following functions: 
+ DATE\$1ADD 
+ DATE\$1DIFF 
+ DATE\$1PART 
+ EXTRACT 

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/clean-rooms/latest/sql-reference/Dateparts_for_datetime_functions.html)

## Variations in results with seconds, milliseconds, and microseconds
<a name="Dateparts_for_datetime_functions-variations-in-results"></a>

Minor differences in query results occur when different date functions specify seconds, milliseconds, or microseconds as date parts: 
+ The EXTRACT function return integers for the specified date part only, ignoring higher- and lower-level date parts. If the specified date part is seconds, milliseconds and microseconds are not included in the result. If the specified date part is milliseconds, seconds and microseconds are not included. If the specified date part is microseconds, seconds and milliseconds are not included. 
+ The DATE\$1PART function returns the complete seconds portion of the timestamp, regardless of the specified date part, returning either a decimal value or an integer as required. 

## CENTURY, EPOCH, DECADE, and MIL notes
<a name="Dateparts_for_datetime_functions-century"></a>

CENTURY or CENTURIES   
AWS Clean Rooms interprets a CENTURY to start with year *\$1\$1\$11* and end with year `###0`:   

```
select extract (century from timestamp '2000-12-16 12:21:13');
date_part
-----------
20
(1 row)

select extract (century from timestamp '2001-12-16 12:21:13');
date_part
-----------
21
(1 row)
```

EPOCH   
The AWS Clean Rooms implementation of EPOCH is relative to 1970-01-01 00:00:00.000000 independent of the time zone where the cluster resides. You might need to offset the results by the difference in hours depending on the time zone where the cluster is located. 

DECADE or DECADES   
AWS Clean Rooms interprets the DECADE or DECADES DATEPART based on the common calendar. For example, because the common calendar starts from the year 1, the first decade (decade 1) is 0001-01-01 through 0009-12-31, and the second decade (decade 2) is 0010-01-01 through 0019-12-31. For example, decade 201 spans from 2000-01-01 to 2009-12-31:   

```
select extract(decade from timestamp '1999-02-16 20:38:40');
date_part
-----------
200
(1 row)

select extract(decade from timestamp '2000-02-16 20:38:40');
date_part
-----------
201
(1 row)

select extract(decade from timestamp '2010-02-16 20:38:40');
date_part
-----------
202
(1 row)
```

MIL or MILS   
AWS Clean Rooms interprets a MIL to start with the first day of year *\$1001* and end with the last day of year `#000`:   

```
select extract (mil from timestamp '2000-12-16 12:21:13');
date_part
-----------
2
(1 row)

select extract (mil from timestamp '2001-12-16 12:21:13');
date_part
-----------
3
(1 row)
```