extrobe
2/14/2017 - 9:48 AM

Convert integer values to a date

Convert integer values to a date

/*Basic script to take a series of integer values and convert them into a date*/

DECLARE @day tinyint = 31
DECLARE @month tinyint = 12
DECLARE @year smallint = 2017

SELECT CAST(CAST(@year AS varchar) + '-' + CAST(@month AS varchar) + '-' + CAST(@day AS varchar) AS DATETIME)