• drew.allen - Thursday, January 19, 2017 1:09 PM

    When working with dates, you DO NOT want to use Year and Month (unless you have a calendar table).  You want to use the first day of the month.  Using Year/Month requires a function on one of the database fields, so it is not SARGable, whereas using the first day of the month may be SARGable (if the first day is calculated from constants/variables).

    Also, by "last" do you mean based on today's date or based on the max date in the table?

    Drew

    I only have month and year in the table, no day.

    MCSE SQL Server 2012\2014\2016