I have a field with a DateTime. I want to ignore the time on that field and add a specified hour.
Here is an example of what I'm looking for, where @h could be any value from 0 to 23. (And I'm using getdate() instead of the field from my table for simplicity here).
declare @h int = 8
select cast(cast(cast(getdate() as date) as nvarchar(50)) + ' ' + CAST(@h as nvarchar(2)) + ':00' as datetime)
How can I write this more simply? Keeping in mind that I'm more interested in readability/maintainability than speed here.