My content table looks like (contentID, title, created). I need to get all content that was created more than 3 weeks ago.
Sql server database, created is datetime type.
My content table looks like (contentID, title, created). I need to get all content that was created more than 3 weeks ago.
Sql server database, created is datetime type.
in MS SQl 2000/2005 you can do this
Select
contactID,
title,
created
from
content
where
created < getdate()-21
How about:
select contentID, title, created
from content
where created < dateadd(week,-3,getdate());
This sticks closer to the question. 21 days is fine, obviously means the same, but I find that it's good to use the terminology used in the question.
For example... a while back I was asked to survey an average of 1 in 50 visitors to a site. I described this as a proportion of 0.02, and the client wasn't happy. I pointed out to the client that they're the same, but I learned my lesson, and now if I change the way that something is described, I make sure I comment to that effect, and preferably don't change it in the first place. If the client wants 3 weeks, do it as 3 weeks, not 21 days.
Try this:
select contentID, title, created from content
where created < dateadd(day,-21,getdate())