Skip to content
A wall of scattered pages from a book

The final word on storage for DATETIME2

  • by

Two years ago I wrote a post that got a lot of traction in the comments at the time. Last month there was renewed interest because one of the commenters noted that the official SQL… 

brown and white clocks

How SQL Server stores data types: dates and times

  • by

This post dives into how SQL Server stores date and time data types in memory and on disk. But first, a note about endianness: CPUs manufactured by Intel and other vendors process binary values in… 

Dates and Times in SQL Server: DATEADD()

  • by

We are now in the home stretch of the long-running series about dates and times in SQL Server and Azure SQL Database. This week we look at one of my favourite T-SQL functions when it… 

Dates and Times in SQL Server: AT TIME ZONE

  • by

Continuing the series on dates and times in SQL Server and Azure SQL Database, this week we look at the hint AT TIME ZONE. In Azure SQL Database, the regional settings of the database are… 

calendar

Dates and Times in SQL Server: DATEPART()

In my previous posts in this series we’ve seen reference to Transact-SQL (T-SQL) functions that are used to get the specific part of a date and/or time (year, month, day, hour, minute, second, etc.). This… 

Dates and Times in SQL Server: SMALLDATETIME

  • by

Last week I spoke about a world wary data type for storing dates and times in a single column, with a granularity of three milliseconds, DATETIME. But let’s say you don’t need that kind of… 

Dates and Times in SQL Server: DATETIME

  • by

Last year I ran a series of posts about Database Fundamentals. Over the next few weeks, I will cover the basics of various date and time data types in SQL Server, when to use them,… 

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… 

Data Efficiency in SQL Server: DATETIME

This is the first in a short series of posts about how I assign efficient data types when designing a new table or database. Use less space with DATETIME2 We all know that the DATETIME column…