Using DateDiff with SQL Server
Working with DateDiff In SQL Server This article is going to discuss the SQL Server DateDiff function and how to use them to find records that fall within a certain date range. I get lots of questions about dates in SQL Server. One common type of question centers around trying to find dates that fall within a date range. These questions usually stem from a lack of understanding about how SQL Server actually stores DateTime data. Data Types To take a quick step back, there are actually 7 date/time focused data types that Microsoft has implemented in SQL Server 2017. Those can be found here. DateTime is deprecated as of 2008 and current and future work should use DateTime2. DateTime2 is described here . It has a enormous range going from January 1, 0001 (1 CE) to December 31, 9999. Dates coming in BCE will be discussed in a future article. SmallDateTime is described here . It...