Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT CONVERT(VARCHAR(10), GETDATE(), 110) what is the meaning of 110 here?

When we convert or cast date in sql, see below sql code

SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] 

it works fine, I just want to know the meaning of 110 in above code. what it does actually, sometimes we use 102, 112 etc. what is the use of that number.

like image 798
Gaurav Avatar asked Apr 26 '13 06:04

Gaurav


2 Answers

That number indicates Date and Time Styles

You need to look at CAST and CONVERT (Transact-SQL). Here you can find the meaning of all these Date and Time Styles.

Styles with century (e.g. 100, 101 etc) means year will come in yyyy format. While styles without century (e.g. 1,7,10) means year will come in yy format.

You can also refer to SQL Server Date Formats. Here you can find all date formats with examples.

like image 91
Himanshu Jansari Avatar answered Sep 21 '22 08:09

Himanshu Jansari


110 is the Style value for the date format.

TSQL Date and Time Styles

like image 33
John Woo Avatar answered Sep 21 '22 08:09

John Woo