How can I apply a converted date to a SQL Server variable?

How can I apply a modified date and time to a variable? This is what I get when I execute the following query in SQL Server Mgmt Studio:

SELECT CONVERT(varchar(15), CAST(GETDATE() AS TIME), 100) 

I have a variable I need to assign to, such.

DECLARE @mytime AS VARCHAR;

SET @mytime = SELECT CONVERT(varchar(15),CAST(GETDATE() AS TIME),100) --incorrect syntax
SELECT @mytime
1 Like

Corresponding tweet for this thread:

Share link for this tweet.

1 Like