Dates (Transact-SQL)
DATEDIFF (Transact-SQL)
SELECT *,
DATEDIFF(MONTH, [first_retail_availability], [discontinued]) AS diff_month
from [dbo].[console_dates] ORDER BY diff_month desc
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed between the specified startdate and enddate.
See DATEDIFF_BIG (Transact-SQL) for a function that handles larger differences between the startdate and enddate values. See Date and Time Data Types and Functions (Transact-SQL) for an overview of all Transact-SQL date and time data types and functions.
DATEDIFF ( datepart , startdate , enddate )

DATEPART (Transact-SQL)
This function returns an integer representing the specified datepart of the specified date.
select [platform_name], [first_retail_availability]
from [dbo].[console_dates]
where DATEPART(MONTH, [first_retail_availability]) -11 = 0

select
[platform_name], [first_retail_availability]
from
[dbo].[console_dates]
where
DATEPART(MONTH, [first_retail_availability]) -12 = 0 OR
DATEPART(MONTH, [first_retail_availability]) -11 = 0
Last updated
Was this helpful?