Red Devil
Red Devil

Reputation: 2403

Create a new date format in SQL Server

I want my date to show as MM.dd.yyyy. But in SQL Server there is no such format to format your date in this format. What I can do is:

select replace(convert(varchar(10), getdate(), 101), '/', '.')

It will give me the expected output. But my question is: can we create a new format all together to display this kind of data without replace?

We have a dateformat options from 0 to 131 in SQL Server. Can we create new format like 132 in SQL Server?

Upvotes: 0

Views: 235

Answers (1)

Ed Bangga
Ed Bangga

Reputation: 13026

You can use SQL Server format() function.

select format(getdate(), 'MM.dd.yyyy') as date

Upvotes: 2

Related Questions