MySQL HOUR() Function

MySQL | HOUR() Function: Learn about the HOUR() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 05, 2022

HOUR() Function

The HOUR() function helps us to get the hour part from any given DateTime. The HOUR() function is really helpful as if sometimes when we are managing a large database and for some reason, we just need the hour part from the DateTime then this function can return the hour part in some seconds.

HOUR() Syntax

SELECT HOUR('datetime');

HOUR() Parameter(s)

  • datetime: For this function, you have to give only one parameter i.e., datetime. You have to provide some datetime from which it will fetch the hour part.

HOUR() Return Value

As a result, it will return the hour part from the date time that you have provided.

MySQL HOUR() Function Example 1

SELECT HOUR('2011-03-12 10:02');
Example 1: MySQL HOUR() Function

MySQL HOUR() Function Example 2

SELECT HOUR('17:02');
Example 2: MySQL HOUR() Function

MySQL HOUR() Function Example 3

SELECT HOUR('20:02:35'); 
Example 3: MySQL HOUR() Function


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.