I have a query like below.
SELECT FORMAT (Submitted_time,'dd-MM-yyyy h:mm tt')
FROM header
And I get the expected output on some of the latest SQL Server as :
27-07-2020 9:15 AM
But when executing same query on some other SQL Server machine, it throws an exception
'FORMAT' is not a recognized built-in function name.
How can I solve this?
FORMATwas introduced a few versions ago; all currently supported versions have it.FORMATisnt a particularly performant function though, you're better off withCONVERTand style codes.FORMATon millions of rows and you won't notice the difference. If you are formatting something for human consumption likely the number of rows will be small anyway