SQL Server Date Formats

Hello to everyone,

In this article, I will talk about Date format change operations in SQL Server.

Date format change is often used in SQL Server.

You can use the codes below to change the date format.

1
SELECT CONVERT(VARCHAR, GETDATE(), 1);
mm/dd/yy 12/30/06
2
SELECT CONVERT(VARCHAR, GETDATE(), 2);
yy.mm.dd 06.12.30
3
SELECT CONVERT(VARCHAR, GETDATE(), 3);
dd/mm/yy 30/12/06
4
select convert(varchar, getdate(), 4)
dd.mm.yy 30.12.06
5
SELECT CONVERT(VARCHAR, GETDATE(), 4);
dd-mm-yy 30-12-06
6
SELECT CONVERT(VARCHAR, GETDATE(), 6);
dd-Mon-yy 30 Dec 06
7
SELECT CONVERT(VARCHAR, GETDATE(), 7);
Mon dd, yy Dec 30, 06
10
SELECT CONVERT(VARCHAR, GETDATE(), 10);
mm-dd-yy 12-30-06
11
SELECT CONVERT(VARCHAR, GETDATE(), 11);
yy/mm/dd 06/12/30
12
SELECT CONVERT(VARCHAR, GETDATE(), 12);
yymmdd 061230
23
SELECT CONVERT(VARCHAR, GETDATE(), 23);
yyyy-mm-dd 2006-12-30
101
SELECT CONVERT(VARCHAR, GETDATE(), 101);
mm/dd/yyyy 12/30/2006
102
SELECT CONVERT(VARCHAR, GETDATE(), 102);
yyyy.mm.dd 2006.12.30
103
SELECT CONVERT(VARCHAR, GETDATE(), 103);
dd/mm/yyyy 30/12/2006
104
SELECT CONVERT(VARCHAR, GETDATE(), 104);
dd.mm.yyyy 30.12.2006
105
SELECT CONVERT(VARCHAR, GETDATE(), 105);
dd-mm-yyyy 30-12-2006
106
SELECT CONVERT(VARCHAR, GETDATE(), 106);
dd Mon yyyy 30 Dec 2006
107
SELECT CONVERT(VARCHAR, GETDATE(), 107);
Mon dd, yyyy Dec 30, 2006
110
SELECT CONVERT(VARCHAR, GETDATE(), 110);
mm-dd-yyyy 12-30-2006
111
SELECT CONVERT(VARCHAR, GETDATE(), 111);
yyyy/mm/dd 2006/12/30
112
SELECT CONVERT(VARCHAR, GETDATE(), 112);
yyyymmdd 20061230

When you run the code, you will get a result like the one below.

SQL Server Date Formats

As you can see, the date values have been changed in a formatted way.

Good luck to everyone in business and life

258 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!