Month: June 2018

Dates In SQL Server: Ambiguous date specification

Dates In SQL Server: Ambiguous date specification

When writing a date in a script, there are a number of ways of doing it, the server uses geographic settings to imply the format. This has some hidden dangers. UK and US dates switch the day and month around. If there are changes in geographic settings and the date format isn’t explicit, there can…

Read More Read More

Dates In SQL Server: Weekdays & Weekends

Dates In SQL Server: Weekdays & Weekends

For reporting or for process management, it’s handy to be able to quickly identify weekdays and weekends. Here I’ll look at a few methods for calculating weekdays and weekends. Some of these come easily from SQL Server, others require a bit more manipulation. Most of this builds on my previous articles on dates: Dates In…

Read More Read More

Dates In SQL Server: Adding & subtracting

Dates In SQL Server: Adding & subtracting

Different DBMS systems have different ways of managing dates. As I’m doing a series of articles on dates, I thought I’d throw some notes down about calculating the difference between some of them. Testing dataset Picking up from my article on Dates In SQL Server: Create Sample Date Ranges I’ll use a sample from there to create…

Read More Read More

Dates In SQL Server: Iteration of Date Ranges

Dates In SQL Server: Iteration of Date Ranges

When performing ETL functions, it’s often required to run processes with iteration over a given date range. Here are some examples of iterating over dates. These methods can also be applied to other cases where we want to do some iteration. After my previous posts looking at dates, particularly Dates In SQL Server: Create Sample Date Ranges. I…

Read More Read More

Dates In SQL Server: Create Sample Date Ranges

Dates In SQL Server: Create Sample Date Ranges

A data set of continuous dates is useful for cursors and creating date tables. Here I look at ways to produce a list of dates. Continuing my series of posts about dates, I wanted to post something which feeds into lots of examples and testing cases I use day to day in development. I’ll also…

Read More Read More