If you're dealing with a format, then what you have to end up with is a string, not a datetime
value - datetime
s (or datetime2
s) don't have a format.
So you need to convert to a string. There's no format that exactly matches what you're asking for, but if you do a conversion and don't give CONVERT
enough space, it truncates the result:
SELECT CONVERT(varchar(16),GETDATE(),120)