day_of_month
1. DAY_OF_MONTH Function
=======day_of_month
1. DAY_OF_MONTH Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe DAY_OF_MONTH function in H2 database is used to extract the day of the month from a given date.
2. Syntax
The syntax for the DAY_OF_MONTH function in H2 database is as follows:
DAY_OF_MONTH(date)
Arguments
date
: The input date from which the day of the month needs to be extracted. It should be a valid date value.
Return
- The DAY_OF_MONTH function returns an integer value representing the day of the month.
3. Notes
- The DAY_OF_MONTH function in H2 database extracts the day component from the given date.
- The input date should be in a valid date format recognized by H2 database, such as 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MI:SS'.
- If the input date is
NULL
, the DAY_OF_MONTH function will returnNULL
.
4. Examples
Here are a few examples demonstrating the usage of the DAY_OF_MONTH function in H2 database:
Example 1 - Extracting the day of the month from a specific date:
SELECT DAY_OF_MONTH(DATE '2022-03-15') AS day;
Output:
day
---
15
Example 2 - Extracting the day of the month from a column of dates:
CREATE TABLE events (
id INT PRIMARY KEY,
event_date DATE
);
INSERT INTO events VALUES (1, DATE '2022-03-15'), (2, DATE '2022-04-20'), (3, DATE '2022-05-10');
SELECT id, event_date, DAY_OF_MONTH(event_date) AS day
FROM events;
Output:
id | event_date | day
---+-------------+----
1 | 2022-03-15 | 15
2 | 2022-04-20 | 20
3 | 2022-05-10 | 10