Back

SQL SERVER Date datatype conversion

SQL SERVER Date datatype conversion



===========================

select CAST('20010302' AS DATETIME)

---------------------------

2001-03-02 00:00:00.000



(1 row(s) affected)



==========================

select CONVERT(CHAR(6), GETDATE(), 12)

------

010323



(1 row(s) affected)



==========================

select CONVERT(CHAR(8), GETDATE(), 112)

------

20010323



(1 row(s) affected)