Post image

Be Wary of Date Formatting in T-SQL

Today’s public service announcement is a reminder to be wary of date formatting in SQL Server. On a recent mailing list discussion, one person demonstrated the following code (which I’ve adapted for this post): SET LANGUAGE ‘us_english’; GO DECLARE @StartDate DATETIME = ‘2017-07-12’; SELECT @StartDate; GO DECLARE @StartDate DATE = ‘2017-07-12’; SELECT @StartDate; GO DECLARE[…]