May 2, 2019 at 11:52 am
select FORMAT(Convert(datetime,GETDATE (),103),'MM/dd/yyyy HH:mm')
May 2, 2019 at 12:51 pm
select FORMAT(Convert(datetime,GETDATE (),103),'MM/dd/yyyy HH:mm')
While that's incredibly simple, as it was designed to be, FORMAT has been tested and documented as being 44 times slower than even poor renditions. Until MS fixes the performance issues with FORMAT (and they won't), don't use FORMAT.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 2, 2019 at 5:45 pm
Because BOL doesn't list/describe all of the available CONVERT styles...
DECLARE @n INT = 0, @v nvarchar(100);
WHILE @n < 10000
BEGIN
BEGIN TRY
SELECT @v = CONCAT(@n, N' ', CONVERT(NVARCHAR(50), GETDATE(), @n));
RAISERROR(@v, 0, 1);
SET @n += 1;
END TRY
BEGIN CATCH
SET @n += 1;
END CATCH;
END;
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply