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.
Filtering on Dates Without Losing the Index
Filtering on dates without losing an index means using searchable ranges; learn half-open boundaries, date and datetime differences, and plan checks.
DATEPART tzoffset: Read the Signed Offset in Minutes
DATEPART tzoffset extracts an offset in minutes. Preserve its sign, test sub-hour values and retain the source temporal type.
SQL SERVER – UDF to Return a Calendar for Any Date for Any Year
Reader Dan Golden built on my weekly calendar function to create a UDF to return a calendar for any date for any year. I fixed a small first and last week bug.
SQL SERVER – Execute Same Query and Statement Multiple Times Using Command GO
Need to run the same statement several times without copy and paste? Put a number after the command GO, like GO 5, and SQL Server runs the batch that many times.







