Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL HOUR Function

by suresh

MySQL Hour function is one of the Date Functions, which returns the Hour from the given time. This MySQL Hour function returns ta value from 0 to 23. However, if the time is huge, the function return value greater than 23.

The syntax of the Hour Function is as shown below:

HOUR(Time or DateTime expression);

MySQL Hour function Example

These examples help you understand the use of hour function. Here, we are returning the hours from different times and a DateTime expression.

SELECT HOUR('11:12:03');

SELECT HOUR('23:12:33');

SELECT HOUR('2019-01-12 03:12:33');

OUTPUT

MySQL HOUR Function 1

Let us see another example of the Hour Date Function. Here, we are using NOW, UTC_TIME, and UTC_TIMESTAMP inside this Hour function to return the Hour from the current date and time.

SELECT HOUR(NOW());

SELECT HOUR(UTC_TIME());

SELECT HOUR(UTC_TIMESTAMP());

OUTPUT

MySQL HOUR Function 2

Hour Function Example 2

The following MySQL queries show you what happens when we try to return the hours from string DateTime, invalid time, or 0 as the time value.

SELECT HOUR(NOW() + 15);

SELECT HOUR('10:12:87');

SELECT HOUR('00:00:00');

OUTPUT

MySQL HOUR Function 3

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy