how to create datepart function in sql db code example Example: get hour from date sql SELECT DATEPART(HOUR, GETDATE());