SQL Interview: 47 Extracting hour from a datetime value
This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Developer Level: Intro
Question:
You need to extract the hour component from a datetime value.
Which function should you use?
Answer:
To do this in SQL Server, you should use the DATEPART function.
2025-05-12