THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL HOUR() Function

❮ MySQL Functions

Example

Return the hour part of a datetime:

SELECT HOUR("2017-06-20 09:34:00");
Try it Yourself »

Definition and Usage

The HOUR() function returns the hour part for a given date (from 0 to 838).

Syntax

HOUR(date)

Parameter Values

Parameter Description
date Required. The datetime value to extract the hour from

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Return the hour part of a datetime: 

SELECT HOUR("838:59:59");
Try it Yourself »

❮ MySQL Functions