See Microsoft's official documentation for more details about the CONVERT function.
Learn more about the ISO 8601 standard.
See Microsoft's official documentation for the DATEPART function.
See Microsoft's official documentation for more information about standard formatting strings.
Learn more about RFC-1123.
See Microsoft's official documentation for more custom formatting tokens.
Also, check out Microsoft's Format Utility, a Windows Forms application for testing format strings.
This utility is meant to help you parse and format dates when using Microsoft SQL Server.
Note that different versions of SQL Server may have different capabilities and behaviors. In particular, the FORMAT function is only available in SQL Server 2012 and newer.
Additionally, culture & localization settings on the database server and clients may influence the behavior of some functions. When in doubt, refer to the documentation: