I have 2 tables: t1 and t2.
- a date column on t1 which is defined as
DateTime2(3) - a date column on t2 which is defined as
DateTime
I am trying to get the value of Date column from t1 and use it to update the Date on t2.
Problem:
When
t1.Date = '2011-07-23 14:01:32.114'
and when I use this value to update t1.Date (which is DateTime) the update statement sets it to:
2011-07-23 14:01:32.113
which is 1 MILISECONDS lower.
Question:
How can I prevent/enforce this update so that SQL casts 2011-07-23 14:01:32.114 value coming from a DateTime2(3) type column again to 2011-07-23 14:01:32.114 so that I do not have that 1 MILISECOND difference on the other table?
In a nutshell, you can’t.
DateTime2has a larger fractional precision thanDateTimedoes.Why don’t you just alter
table1to useDateTime2instead ofDateTime?From MSDN
and