Answers for "sql server create date"

SQL
2

datefromparts mssql

DATEFROMPARTS ( year, month, day )
Posted by: Guest on April-15-2020
0

create date sql

-- SQL Server
SELECT cast(cast(@year*10000 + @month*100 + @day as varchar(255)) as date)
-- Oracle:TO_DATE(string, format)
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;
-- SQL Server: CONVERT(data_type, string, style). Cf source link for style codes.
SELECT datefromparts(@year, @month, @day)
SELECT CONVERT(DATETIME, '2012-06-05', 102);	  -- Raises error if impossible
SELECT TRY_CONVERT(DATETIME, '2012-06-05', 102);  -- Returns Null if impossible
-- MySQL: STR_TO_DATE(string, format): 
SELECT STR_TO_DATE('2012-06-05','%Y-%m-%d');
Posted by: Guest on August-23-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language