MySQL HOUR() Function

MySQL HOUR() function; In this tutorial, i am going to show you MySQL HOUR() function with the help of examples.

MySQL HOUR() Function

MySQL Hour() Function is MySQL DateTime function which is responsible to fetch the hour part from the datetime value specified in the query.

Syntax of MySQL HOUR() Function

The basic syntax of MySQL HOUR() function is:


The time here is the value that you want to extract the hour from the given DateTime value.

Example 1 – MySQL HOUR() Function

Let’s take an first example using MySQL HOUR() function; as follows:

SELECT HOUR('11:40:30');


| HOUR('11:40:30') |
|               11 |

Example 2 – MySQL HOUR() Function

Let’s take an second example using the mysql hour() function; as follows:

SELECT HOUR('280:40:28');


| HOUR('280:40:28') |
|               280 |

Example 3 – MySQL HOUR() Function

Let’s take an third example using hour() function; as follows:

SELECT HOUR('-310:35:27');


| HOUR('-310:35:27') |
|                310 |

Example 4 – MySQL HOUR() with Now() Function

Let’s take an exmaple using hour() with NOW() function; as follows:



| HOUR(NOW)          |
|                16  |


MySQL HOUR() Function tutorial, you have learned how to use MySQL HOUR() function.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *