YEAR()

Description

The YEAR() or TOYEAR() function returns the year part for a given date (a number from 1000 to 9999).

Syntax

1. > YEAR(date)
2. > TOYEAR(date)

Arguments

Arguments Description
date Required. The date/datetime to extract the year from

Examples

1. > drop table if exists t1;
2. > create table t1(a date, b datetime);
3. > insert into t1 values('20211223','2021-10-22 09:23:23');
4. > insert into t1 values('2021-12-23','2021-10-22 00:23:23');

6. > select year(a), toyear(b)from t1;
7. +---------+-----------+
8. | year(a) | toyear(b) |
9. +---------+-----------+
10. |    2021 |      2021 |
11. |    2021 |      2021 |
12. +---------+-----------+

Constraints

The date type supports only yyyy-mm-dd and yyyymmdd for now.

Currently, MatrixOne doesn’t support select function() without from tables.