Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
macca
Posting Yak Master
146 Posts |
Posted - 2013-09-11 : 10:06:19
|
I am doing a Select that contains a DATEADD and I want to get the records 330 days after the Date in the column DatTimeIssued in table Record. Here is the code I am using:SELECT No, CustomerIDFROM LicenceRecordWHERE (LicenceStatus = 'Active') AND (RenewalStatus = 'Current') AND (LicenceDateTimeIssued = DATEADD(DAY, 330, LicenceDateTimeIssued)) I am not getting any records returned but I should be as the data fits the query criteria.Anyone know what I am doing wrong ? |
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-09-11 : 10:09:56
|
(LicenceDateTimeIssued = DATEADD(DAY, 330, LicenceDateTimeIssued) will never be true. one or the other needs to be a different column.djj |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2013-09-11 : 10:16:22
|
how would you write it then ? |
|
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-09-11 : 10:52:02
|
Not knowing the columns available, I cannot help.Maybe something like RecordDate > DATEADD(DAY, 330, LicenceDateTimeIssued) djj |
|
|
ScottPletcher
Aged Yak Warrior
550 Posts |
Posted - 2013-09-11 : 15:20:31
|
AND (LicenceDateTimeIssued < DATEADD(DAY, -330, GETDATE())) |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2013-09-12 : 05:34:56
|
Thanks guys for all your help.That worked for me. |
|
|
|
|
|