T-SQL.co.uk
0 votes
I want to be able to pull back the DATE from SQL which displays in the format " Day Name Date Number + Suffix Month Year
by

1 Answer

0 votes
-- Replace @date below with the date Value you want to convert
SELECT DATENAME(weekday, @Date) + ' ' + CASE WHEN DAY(@Date) in (1,21,31)
THEN convert(varchar,DAY(@Date)) + 'st'
WHEN DAY(@Date) IN (2,22) then convert(varchar,DAY(@Date)) + 'nd'
WHEN DAY(@Date) IN (3,23) then convert(varchar,DAY(@Date)) + 'rd'
ELSE convert(varchar,DAY(@Date)) + 'th ' end +
DATENAME(month, @Date)  + ' ' + convert(varchar,year(@Date)) as [English Suffix Date]
by
Welcome to T-SQL.co.uk, where you can ask questions and receive answers from other members of the community.
12 questions
15 answers
0 comments
1,643 users