SQL-Mac

DateTime2 not like DateTime

20th April 2018
sql server
sql server
replication
Last updated:13th November 2024
1 Minutes
43 Words

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)
Article title:DateTime2 not like DateTime
Article author:sqlmac
Release time:20th April 2018