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

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

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 */
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

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

The jOOQ Logo