Calculate Age in SQL Server by counting completed birthdays, not calendar years. This post compares DATEDIFF, a DATEADD correction and a compact integer version on a bike club table, handles February 29 birthdays and ends with a reusable function for age on any date.
SQL SERVER – 2008 – SQL Server Start Time
SQL Server 2008 records when it started in sys.dm_os_sys_info. One SELECT of sqlserver_start_time gives you the SQL Server start time. It does not work on 2005.
DATETRUNC: Use ISO Week Boundaries With Explicit Date Types
DATETRUNC can give an ISO week its Monday boundary without changing session settings. I also keep the input date type explicit. A boundary calculation should reveal both its calendar rule and its return type.
SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function Part 4
In Day of the Week Function Part 4, I answer why I write a UDF when DATENAME exists (I just like it) and show the one line DATENAME version.
SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 3
Nanda Kumar improved the UDF to get the day of the week: it now uses the date you pass in instead of GETDATE() and handles Saturday correctly.
SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2
Mihir Popat improved my Day of the Week Function with @@DATEFIRST, so Sunday does not have to be the first day of the week. Here is his UDF.
EOMONTH: Month Ends Are Different From DATEADD Month Clipping
EOMONTH gives me a month-end date when that is the actual reporting requirement. DATEADD moves a date by a month. These operations can agree for one step and disagree on the next.







