Date and Time Formats in SQL Server
Published: 3rd May 2013
There are numerous times you might want your dates returned in a different format and SQL Server will cater for this.

Running the following script will show the different date and time formats you have available…

declare @conversion tinyint = 101,
        @datetime datetime = current_timestamp

declare @dateFormat table
(
    formatCode varchar(40),
    result varchar(25)
)

while @conversion <= 150
begin
    begin try
        insert into @dateFormat
        select 'CONVERT(varchar, current_timestamp, ' +
                CONVERT(varchar, @conversion) + ')',
                CONVERT(varchar, @datetime, @conversion)
    end try
    begin catch
    end catch

    set @conversion += 1
end

select *
from @dateFormat
Comments:
NB: Comments will only appear once they have been moderated.