sql server date format code example

Example 1: sql server convert string to date

Cast( '2011-07-07' as date ) as convertedDate

Example 2: SQL Date Format

SELECT FORMAT(dbo.column, 'M/dd/yyyy')

Example 3: sql server obtener fecha en formato dd/mm/yyyy

convert( datetime, fecha, 103 )

Example 4: sql convert date to string yyyy-mm-dd

select CONVERT(char(10), GetDate(),126)
/* 2020-12-23 */

Example 5: sql server obtener fecha en formato dd/mm/yyyy

FORMAT (getdate(), 'dd-MM-yy')

Example 6: sql date format

default date format of my sql - YYYY-MM-DD

Tags:

Misc Example