Beginner

274. HOUR Function

Learn how to extract the hour component from a time or timestamp.

📘 Lesson 274 of 728 ⏱ 8 min 🎯 Intermediate

The HOUR function extracts the hour component from a time or timestamp value, commonly returning a value from 0 through 23.

Hour-level analysis can reveal when customers transact, when systems are busiest, or when operational events occur.

Identify the hour during which each transaction occurred.

SQL
SELECT
    TransactionID,
    TransactionTime,
    HOUR(TransactionTime) AS TransactionHour
FROM Transactions;

HOUR is useful for call-center analysis, transaction monitoring, website activity, staffing, and operational performance analysis.

  • HOUR extracts the hour component.
  • The result is commonly between 0 and 23.
  • It is useful for time-of-day analysis.
  • It can support workload analysis.
  • Function support varies between databases.
What does HOUR return?

HOUR returns the hour component from a time or timestamp value.

Why analyze transactions by hour?

Hourly analysis can identify peak activity periods and help with staffing and operational planning.

Have you finished this lesson?

Introduction to SQL – All Lessons