Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12

DAY_OF_YEAR

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Extract the DAY_OF_YEAR value from a datetime value.

The DAY_OF_YEAR function is a short version of the EXTRACT, passing a DatePart.DAY_OF_YEAR value as an argument.

SELECT day_of_year(DATE '2020-02-03');
create.select(dayOfYear(Date.valueOf("2020-02-03"))).fetch();

The result being

+-------------+
| day_of_year |
+-------------+
|          33 |
+-------------+

Dialect support

This example using jOOQ:

dayOfYear(Date.valueOf("2020-02-03"))

Translates to the following dialect specific expressions:

ASE, Sybase

datepart(dy, '2020-02-03 00:00:00.0')

Aurora MySQL, DB2, Hana, MariaDB, MySQL

dayofyear(TIMESTAMP '2020-02-03 00:00:00.0')

Aurora Postgres, CockroachDB, Postgres

extract(DOY FROM TIMESTAMP '2020-02-03 00:00:00.0')

H2, HSQLDB

extract(DAY_OF_YEAR FROM TIMESTAMP '2020-02-03 00:00:00.0')

MemSQL

dayofyear({ts '2020-02-03 00:00:00.0'})

Oracle

to_number(to_char(TIMESTAMP '2020-02-03 00:00:00.0', 'DDD'))

SQLDataWarehouse, SQLServer

datepart(dy, CAST('2020-02-03 00:00:00.0' AS DATETIME2))

SQLite

CAST(strftime('%j', '2020-02-03 00:00:00.0') AS int)

Access, BigQuery, ClickHouse, Derby, DuckDB, Exasol, Firebird, Informix, Redshift, Snowflake, Teradata, Trino, Vertica, YugabyteDB

/* UNSUPPORTED */

(These are currently generated with jOOQ 3.20, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo