Different Date Formats In SQL Server

In this article, we are going to explore different SQL Convert Date formats to use to write SQL queries.

SQL Server provides so many options that you can use to format a date/time string in SQL.
An early consideration is the actual date/time required. The most common is the current date/time running getdate().

Different Date Formats in SQL Server :

SQL Statement

Format

Date

select convert(varchar, getdate(), 1) mm/dd/yy 02/12/22
select convert(varchar, getdate(), 2) yy.mm.dd 22.02.12
select convert(varchar, getdate(), 3) dd/mm/yy 12/02/22
select convert(varchar, getdate(), 4) dd.mm.yy 12.02.22
select convert(varchar, getdate(), 5) dd-mm-yy 12-02-22
select convert(varchar, getdate(), 6) dd-Mon-yy 12 Feb 22
select convert(varchar, getdate(), 7) Mon dd, yy Feb 12, 22
select convert(varchar, getdate(), 8) hh:mm:ss 11:03:00
select convert(varchar, getdate(), 9) Mon dd yyyy hh:mm:ss:nnn AM/PM Feb 12 2022 11:03:00:417AM
select convert(varchar, getdate(), 10) mm-dd-yy 02-12-22
select convert(varchar, getdate(), 11) yy/mm/dd 22/02/12
select convert(varchar, getdate(), 12) yymmdd 22/02/12
select convert(varchar, getdate(), 13) dd Mon yyyy hh:mm:ss:nnn AM/PM 12 Feb 2022 11:03:00:417
select convert(varchar, getdate(), 14) hh:mm:ss:nnn 11:03:00:417
select convert(varchar, getdate(), 20) yyyy-mm-dd hh:mm:ss 2022-02-12 11:06:50
select convert(varchar, getdate(), 21) yyyy-mm-dd hh:mm:ss:nnn 2022-02-12 11:14:12
select convert(varchar, getdate(), 22) mm/dd/yy hh:mm:ss AM/PM 02/12/22 11:14:21 AM
select convert(varchar, getdate(), 23) yyyy-mm-dd 2022-02-12
select convert(varchar, getdate(), 24) hh:mm:ss 11:14:29
select convert(varchar, getdate(), 25) yyyy-mm-dd hh:mm:ss:nnn 2022-02-12 11:14:29
select convert(varchar, getdate(), 100) Mon dd yyyy hh:mm AM/PM Feb 12 2022 11:14 AM
select convert(varchar, getdate(), 101) mm/dd/yyyy 02/12/2022
select convert(varchar, getdate(), 102) yyyy.mm.dd 2022.02.12
select convert(varchar, getdate(), 103) dd/mm/yyyy 12/02/2022
select convert(varchar, getdate(), 104) dd.mm.yyyy 12.02.2022
select convert(varchar, getdate(), 105) dd-mm-yyyy 12-02-2022
select convert(varchar, getdate(), 106) dd Mon yyyy 12 Feb 2022
select convert(varchar, getdate(), 107) Mon dd, yyyy Feb 12, 2022
select convert(varchar, getdate(), 108) hh:mm:ss 11:35:05
select convert(varchar, getdate(), 109) Mon dd yyyy hh:mm:ss:nnn AM/PM Feb 12 2022 11:35:05:937AM
select convert(varchar, getdate(), 110) mm-dd-yyyy 02-12-2022
select convert(varchar, getdate(), 111) yyyy/mm/dd 2022/02/12
select convert(varchar, getdate(), 112) yyyymmdd 20220212
select convert(varchar, getdate(), 113) dd Mon yyyy hh:mm:ss:nnn 12 Feb 2022 11:40:06:220
select convert(varchar, getdate(), 114) hh:mm:ss:nnn 11:40:06:220
select convert(varchar, getdate(), 120) yyyy-mm-dd hh:mm:ss 2022-02-12 11:40:06
select convert(varchar, getdate(), 121) yyyy-mm-dd hh:mm:ss:nnn 2022-02-12 11:40:06
select convert(varchar, getdate(), 126) yyyy-mm-dd T hh:mm:ss:nnn 2022-02-12 11:40:06
select convert(varchar, getdate(), 127) yyyy-mm-dd T hh:mm:ss:nnn 2022-02-12 11:40:06
select convert(varchar, getdate(), 130) dd mmm yyyy hh:mi:ss:nnn AM/PM 11 ??? 1443 11:40:06:220AM
select convert(varchar, getdate(), 131) dd mmm yyyy hh:mi:ss:nnn AM/PM 11/07/1443 11:40:06:220AM

 

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories