How to format date on MS SQL Server 2008
问题 I would like to format dates based on a pattern like for example 22/01/2015 or 2016-12-15. In the .NET Framework we have DateTime -> ToString() method which accepts formats as argument or even string.Format, which does the same. Is there any function on MS SQL Server 2008 that formats date based on a argument pattern? 回答1: I had a similar problem in SQL 2012 they have a great function called format which you could pass in a date and the format you require SELECT FORMAT(GETDATE(), 'dd/mm/yyy')