I\'m surprised not to be able to find this question here already.
I have a date time var and I want to convert it to a string so that I can append it to another stri
There are many different ways to convert a datetime to a string. Here is one way:
datetime
SELECT convert(varchar(25), getdate(), 121) – yyyy-mm-dd hh:mm:ss.mmm
See Demo
Here is a website that has a list of all of the conversions:
How to Format datetime & date in SQL Server