Cleaning messy data With T-SQL means trimming text, parsing dates safely, and preserving rejected source rows for correction and replay.
SQL SERVER – Various Leap Year Logics
Dividing by 4 is not enough to find a leap year. Readers shared various leap year logics in the comments, and here are the best of them.
Detect a Leap Year in T-SQL: Four Simple Ways
Detecting a Leap Year in T-SQL takes one rule or one date trick. This post tests four ways on SQL Server 2025: the calendar rule, EOMONTH, TRY_CONVERT and DATEDIFF. It shows that all four agree on 209 years, explains the century years that trip people up, and answers how leap years affect date math.
Date Functions Quiz: What Does DATEDIFF Count?
This Date Functions Quiz asks what DATEDIFF returns for two dates one day apart, when the unit is year. The answer is 1, because DATEDIFF counts boundaries crossed. A tested script shows an age calculation that works, plus DATETRUNC and EOMONTH.
Watermarks for Incremental Extracts
Watermarks for incremental extracts need clear boundaries, durable checkpoints, and a plan for late updates, deletes, and missed rows.
SQL SERVER – DATEDIFF – Accuracy of Various Dateparts
Why does DATEDIFF say 1 minute between two times only 3 seconds apart? It is not a bug. Here is how DATEDIFF counts datepart boundaries.
SQL SERVER 2012 – DateTime Functions – DATEFROMPARTS() – DATETIMEFROMPARTS() – DATETIME2FROMPARTS()
SQL Server 2012 adds seven new datetime functions, such as DATEFROMPARTS, DATETIMEFROMPARTS and EOMONTH. A quick look at building dates from their parts.






