Sql Server Date Diff

Apr 11, 2023

Related to:: SQL - SQL Server - MySQL

On SQL Server, we can specify, as the first parameter the unit of the return:

year, month, day, week, hour, minute, second, millisecond

SQL Server
SELECT 
	DATEDIFF(day, delivery_date, GETDATE()) as delivered_in_days
...
WHERE
	DATEDIFF(day, delivery_date, GETDATE()) >= 10

On MySQL, it only returns the difference in days.

MySQL
DATEDIFF(delivery_date, GETDATE()) >= 10

Graph View