iso_day_of_week
1. ISO_DAY_OF_WEEK Function
=======iso_day_of_week
1. ISO_DAY_OF_WEEK Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe ISO_DAY_OF_WEEK function in H2 database is used to retrieve the ISO day of the week for a given date.
2. Syntax
The syntax for the ISO_DAY_OF_WEEK function in H2 database is as follows:
ISO_DAY_OF_WEEK(date)
Arguments
date
: The date for which the ISO day of the week needs to be determined. It should be a valid date value.
Return
- The ISO_DAY_OF_WEEK function returns an integer representing the ISO day of the week for the given date. The ISO day of the week ranges from 1 (Monday) to 7 (Sunday).
3. Notes
- The ISO_DAY_OF_WEEK function in H2 database follows the ISO-8601 standard for determining the day of the week. According to this standard, Monday is considered the first day of the week.
- The input date should be a valid date value in the format 'YYYY-MM-DD'. If the input is not a valid date or is in a different format, the ISO_DAY_OF_WEEK function will return
NULL
. - Ensure that the input date is within the supported range of the H2 database.
4. Examples
Here are a few examples demonstrating the usage of the ISO_DAY_OF_WEEK function in H2 database:
Example 1 - Retrieving the ISO day of the week for a specific date:
SELECT ISO_DAY_OF_WEEK('2022-01-01') AS iso_day;
Output:
iso_day
-------
6
Example 2 - Retrieving the ISO day of the week for dates stored in a table:
CREATE TABLE events (
id INT PRIMARY KEY,
event_date DATE
);
INSERT INTO events VALUES (1, '2022-01-01'), (2, '2022-01-05'), (3, '2022-01-10');
SELECT id, event_date, ISO_DAY_OF_WEEK(event_date) AS iso_day
FROM events;
Output:
id | event_date | iso_day
---+-------------+--------
1 | 2022-01-01 | 6
2 | 2022-01-05 | 3
3 | 2022-01-10 | 1
5. Related Functions
- day_of_week - Calculate day of the week (Sunday = 1, Monday = 2, etc.)
- DAY_NAME - Retrieve the name of the day of the week