Tools › DATEADD / DATEDIFF

T-SQL DATEADD and DATEDIFF generator

SQL Server wants DATEADD(day, -7, GETDATE()), not DATE_SUB. The unit is a word, not a string. This writes the line for you.

The arguments swap depending on the function. DATEADD is (unit, number, date). DATEDIFF is (unit, start, end). People search this every week because the muscle memory is MySQL.

Use day not dd if someone else has to read it. For “last week” as a calendar week, the generator is not enough — see last week’s orders and DATEADD.

Learn it on a real ticket

Monday is free on WorkSQL. Write the T-SQL yourself. We mark it like a colleague would.

Clock in free