Home DateTime2 not like DateTime
Post
Cancel

DateTime2 not like DateTime

I came across an article on SQL Server Central written by Claudio Silva (blog/twitter) discussing that you can’t do arithmetic operations on DateTime2 like you can with DateTime.

For example:

Old Way

1
OrderDate < GETDATE() -1

You need to do something like this:

1
OrderDate < DATEADD(dd, -1, @vOrderDate)
This post is licensed under CC BY 4.0 by the author.