How can I build a date from 3 columns of float datatype?
Solution 1:
The DATEFROMPARTS()
function is an option (... returns a date value that maps to the specified year, month, and day values):
SELECT DATEFROMPARTS([YEAR], [MONTH], [DAY]) AS CREATEDATE
FROM (VALUES
(2, 11, 2021),
(1, 10, 2021),
(12, 10, 2021),
(22, 09, 2021)
) t ([DAY], [MONTH], [YEAR])
Or with the actual table:
SELECT DATEFROMPARTS([YEAR], [MONTH], [DAY]) AS CREATEDATE
FROM t1