Created
November 14, 2023 18:52
-
-
Save fernandezja/fa08d06688a2b9888b9ca4299444c0cc to your computer and use it in GitHub Desktop.
Add time to date SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Add time to date SQL Server | |
-------------------------------------------------------------- | |
DECLARE @Hour TIME = '20:00', | |
@Today VARCHAR(10) = CONVERT(VARCHAR(10), GETDATE(), 121) | |
DECLARE @TodayWithHourString VARCHAR(100) = CONCAT(@Today, ' ', @Hour) | |
DECLARE @TodayWithHour DATETIME2(0) = CONVERT(DATETIME2(0), @TodayWithHourString) | |
SELECT | |
Hour = @Hour, | |
Today = @Today, | |
TodayWithHourString = @TodayWithHourString, | |
TodayWithHour = @TodayWithHour |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example