• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

MySQL Command: HOUR()

December 20, 2023

MySQL Command: HOUR()

MySQL is a popular open-source relational database management system that is widely used for storing and managing data. It provides a wide range of functions and commands to manipulate and retrieve data efficiently. One such command is HOUR(), which allows users to extract the hour component from a given time or datetime value.

Syntax

The syntax for the HOUR() command is as follows:

HOUR(time_value)

Here, time_value can be a valid time or datetime value.

Usage

The HOUR() command is primarily used to extract the hour component from a given time or datetime value. It returns an integer value between 0 and 23, representing the hour of the day.

Let’s consider an example to understand its usage:

SELECT HOUR('2022-01-01 09:30:45');

This query will return the hour component from the given datetime value, which is 9.

The HOUR() command can also be used in conjunction with other MySQL functions and commands to perform complex operations. For example, you can use it to filter records based on a specific hour:

SELECT * FROM table_name WHERE HOUR(timestamp_column) = 12;

This query will retrieve all records from the specified table where the hour component of the timestamp column is 12.

Examples

Here are a few more examples to illustrate the usage of the HOUR() command:

SELECT HOUR('12:30:45');

This query will return the hour component from the given time value, which is 12.

SELECT HOUR('2022-01-01');

This query will return 0 as there is no time component in the given date value.

Summary

The HOUR() command in MySQL is a useful function for extracting the hour component from a given time or datetime value. It returns an integer value between 0 and 23, representing the hour of the day. It can be used in various scenarios, such as filtering records based on a specific hour. To learn more about MySQL and its capabilities, consider exploring Server.HK, a leading VPS hosting company that provides reliable and efficient hosting solutions.

Recent Posts

  • How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  • Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  • Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  • Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot