Reputation: 91
I would like to have a datetime variable composed of the current date and a time that I would have defined.
I tried this :
DECLARE @limit datetime2;
SET @limit = CONVERT (date, GETDATE()) + ' 05:00:00'
But this way doesn't work well because I can't add a varchar
to a date
.
Upvotes: 0
Views: 98
Reputation: 1340
You can also achieve by using CONCAT
in SQL
DECLARE @limit datetime2;
SET @limit = CONCAT(CONVERT (date, GETDATE()) , ' 05:00:00')
SELECT @limit
Upvotes: 1
Reputation: 2986
You can try:
DECLARE @limit datetime2;
SET @limit = DATEADD(day, DATEDIFF(day, 0, GETDATE()), '05:00:00')
select @limit
Upvotes: 4