You can get date and time separately from a datetime value in two ways: formatted text or real DATE and TIME values. The tests here show how each one sorts, filters and fails, and which one to keep in your code.
Measuring Time Between Workflow Steps With LEAD
Status rows hold timestamps, not durations. I use LEAD to measure each step, keep unfinished steps NULL, and show why zero ruins your averages.
Comparing Session SET Options Between SSMS and the Application
Fast in SSMS, slow in the app? The query may be fine and the connection settings different. Here is how to check, with nothing to set up.
Time-Limited Access: Expiring Grants With a Valid-Until Column
A ValidUntil column does nothing by itself. Here is how to make the read path enforce it, with a demo you can run.
DATEDIFF Counts Boundaries, Not Time: Getting Durations Right
A report can say one year of service after a single day. Here is why DATEDIFF does that, and what to use instead.
SQL SERVER – SmallDateTime and Precision – A Continuous Confusion
SmallDateTime and precision confuse a lot of people. I explain what the precision really is, using a Facebook question from Raghavendra.
SQL SERVER – Saturday Fun Puzzle with SQL Server DATETIME2 and CAST
A Saturday fun puzzle with DATETIME2 and CAST in SQL Server 2012. Run each script one at a time, guess the output, and learn something new.






