• I'm not 100% sure what you are looking for but It would seem that DATEPART would be your friend as it appears you are trying to grab the year and month from a datetime field.

    Here are some examples...

    DECLARE @somedate DATETIME = GETDATE()

    SELECT

    @somedate AS myDate,

    DATEPART(year, @somedate) AS justYear,

    DATEPART(month, @somedate) AS justMonth,

    '5' + CAST(DATEPART(year, @somedate) AS VARCHAR(4)) + CAST(DATEPART(month, @somedate) AS VARCHAR(2)) AS endResult


    SELECT quote FROM brain WHERE original = 1
    0 rows returned