create date sql

Solutions on MaxInterview for create date sql by the best coders in the world

showing results for - "create date sql"
Mya
28 Mar 2018
1-- SQL Server
2SELECT cast(cast(@year*10000 + @month*100 + @day as varchar(255)) as date)
3-- Oracle:TO_DATE(string, format)
4SELECT TO_DATE('2012-06-05', 'YYYY-MM-DD') FROM dual;
5SELECT TO_DATE('05/06/2012 13:25:12', 'DD/MM/YYYY HH24:MI:SS') FROM dual;
6-- SQL Server: CONVERT(data_type, string, style). Cf source link for style codes.
7SELECT datefromparts(@year, @month, @day)
8SELECT CONVERT(DATETIME, '2012-06-05', 102);	  -- Raises error if impossible
9SELECT TRY_CONVERT(DATETIME, '2012-06-05', 102);  -- Returns Null if impossible
10-- MySQL: STR_TO_DATE(string, format): 
11SELECT STR_TO_DATE('2012-06-05','%Y-%m-%d');