Website Index

We provide Custom, Bespoke and Open Source Database, Data Acquisition, Data Logging, Test, Measurement, Instrumentation, Control, Accounting, Business, Financial and Management Software solutions. We have been looking after our customers since 1994.

SQL Server DATEDIFF

The SQL Server DATEDIFF keyword is useful in SQL WHERE clauses.

For records over 7 days old:

WHERE DATEDIFF(day, DateRecordCreated, GETDATE()) > 7

For records over 1 month old:

WHERE DATEDIFF(month, DateRecordCreated , GETDATE()) > 1

The GETDATE() function gets the current date / time.