Friday, July 30, 2010

SQL Server Date Format and Convert DateTime to particular format

    I was playing with different date format in SQL Server as need to display date in YYYY-MM-DD HH:MI:SS.MMM format. I knew there is a CONVERT function which can do this however I did not have the exact parameter value to convert my date to mentioned format. I got really use full chart on internet which provides different option and parameter value for CONVERT function. For my case syntax is

SELECT CONVERT(nvarchar(23),GetDate(),121)

You can check complete table here.

Happy Programming !!!!

Chirag Darji
ASP.NET Consultant & Trainer