Class Hour
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the HOUR time extraction function that returns the hour component of a datetime.
public class Hour : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
Hour
- Implements
Remarks
The HOUR function extracts the hour as an integer (0-23) from a datetime or time value. For example, HOUR('2024-03-15 14:30:00') returns 14. This is useful for time-of-day analysis, hourly grouping, or filtering records by specific hours.
Examples
Extract the hour component from each event timestamp:
var schema = manager.LoadSchema("events");
var logs = schema["event_log"];
var query = new Query()
.Select([ logs["id"], new Expression("event_hour", new Hour(logs["occurred_at"])) ])
.From(logs);
var results = manager.Retrieve(query);
Constructors
- Hour(IEnumerable<IElement>)
Initializes a new instance of HOUR for a composed expression (e.g. HOUR(DATEADD(...))).
- Hour(IElement)
Initializes a new instance of HOUR for any element.
- Hour(Column)
Initializes a new instance of HOUR for a column.
- Hour(Expression)
Initializes a new instance of HOUR for an expression.