convert date sql server yyyy mm dd code example
Example 1: sql server cast date dd/mm/yyyy
SELECT cast(convert(date, '23/07/2009', 103) AS DATE)
select convert(date, '23/07/2009', 103)
Example 2: sql to date
SELECT TO_DATE('2012-06-05', 'YYYY-MM-DD') FROM dual;
SELECT TO_DATE('05/06/2012 13:25:12', 'DD/MM/YYYY HH24:MI:SS') FROM dual;
SELECT CONVERT(DATETIME, '2012-06-05', 102);
SELECT TRY_CONVERT(DATETIME, '2012-06-05', 102);
SELECT STR_TO_DATE('2012-06-05','%Y-%m,%d');
Example 3: sql convert date to string yyyy-mm-dd
select CONVERT(char(10), GetDate(),126)
Example 4: sql server date format yyyy-mm-dd
convert(varchar, [column_date], 20)
convert(varchar, [column_date], 23)