<<<<<<< HEAD minute | H2 | SQLDoc
Skip to main content

minute

1. MINUTE Function

======= minute | H2 Function | SQLDoc

minute

1. MINUTE Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The MINUTE function in H2 database is used to extract the minute component from a given time or timestamp value.

2. Syntax

The syntax for the MINUTE function in H2 database is as follows:

MINUTE(time)
MINUTE(timestamp)

Arguments

  • time: The time value from which to extract the minute component. It should be a valid time value in the format 'HH:MI:SS' or 'HH:MI'.
  • timestamp: The timestamp value from which to extract the minute component. It should be a valid timestamp value in the format 'YYYY-MM-DD HH:MI:SS'.

Return

  • The MINUTE function returns an integer value representing the minute component of the given time or timestamp.

3. Notes

  • The MINUTE function in H2 database returns values in the range of 0 to 59.
  • If the input time or timestamp is not in a valid format or is NULL, the MINUTE function will return NULL.
  • It's important to ensure that the input value is of the correct data type to avoid any errors.

4. Examples

Here are a few examples demonstrating the usage of the MINUTE function in H2 database:

Example 1 - Extracting the minute component from a time value:

SELECT MINUTE(TIME '10:25:45') AS minute;

Output:

minute
------
25

Example 2 - Extracting the minute component from a timestamp value:

SELECT MINUTE(TIMESTAMP '2022-01-15 08:55:30') AS minute;

Output:

minute
------
55

Example 3 - Extracting the minute component from a column:

CREATE TABLE appointments (
id INT PRIMARY KEY,
start_time TIME,
end_time TIME
);

INSERT INTO appointments VALUES (1, TIME '09:30:00', TIME '10:45:00'),
(2, TIME '13:15:00', TIME '14:30:00'),
(3, TIME '16:45:00', TIME '17:15:00');

SELECT id, start_time, MINUTE(start_time) AS start_minute,
end_time, MINUTE(end_time) AS end_minute
FROM appointments;

Output:

id | start_time | start_minute | end_time | end_minute
---+------------+--------------+----------+------------
1 | 09:30:00 | 30 | 10:45:00 | 45
2 | 13:15:00 | 15 | 14:30:00 | 30
3 | 16:45:00 | 45 | 17:15:00 | 15
  • hour - Extract the hour component from a time or timestamp value
  • second - Extract the second component from a time or timestamp value