I have either discovered a bug or I am doing something totally wrong, but when I try to subtract days off of a Date field using DateAdd in a constraint, SQL Enterprise Manager is saying the constarint is not valid. My code is very simple. The constraint that does not work is
[MyDateTime1] < DateAdd(d,-6,[MyDateTime2])
I was playing around with it and every value for the number seems to work from -1 on up, but anything below -1, i.e -2 and lower does not work. I thought at first it had to do with the dash character itself, but -1 works. I then tried weird workarounds like using
[MyDateTime1] < DateAdd(d,Sign(-1)*6,[MyDateTime2])
but that didn't work either.
Is this a bug or am I doing something wrong? If it is a bug, is there a workaround? I don't want to resort to Triggers if possible...
Thanks in advance!!!
[MyDateTime1] < DateAdd(d,-6,[MyDateTime2])
I was playing around with it and every value for the number seems to work from -1 on up, but anything below -1, i.e -2 and lower does not work. I thought at first it had to do with the dash character itself, but -1 works. I then tried weird workarounds like using
[MyDateTime1] < DateAdd(d,Sign(-1)*6,[MyDateTime2])
but that didn't work either.
Is this a bug or am I doing something wrong? If it is a bug, is there a workaround? I don't want to resort to Triggers if possible...
Thanks in advance!!!