查询以获取超过 3 周的内容 [英] Query to get content older than 3 weeks
问题描述
我的内容表看起来像(contentID
、title
、created
).我需要获取超过 3 周前创建的所有内容.
My content table looks like (contentID
, title
, created
). I need to get all content that was created more than 3 weeks ago.
使用 SQL Server 数据库并且 created
是 datetime
数据类型.
Using a SQL Server database and created
is of datetime
datatype.
推荐答案
怎么样:
select contentID, title, created
from content
where created < dateadd(week,-3,getdate());
这更接近问题.21 天很好,显然意思相同,但我发现使用问题中使用的术语很好.
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.
例如……不久前,我被要求调查网站访问者中平均每 50 名访问者中的 1 名.我将其描述为 0.02 的比例,客户并不满意.我向客户指出它们是相同的,但我吸取了教训,现在如果我改变描述某事的方式,我确保我对此发表评论,并且最好不要在第一次改变它地方.如果客户想要 3 周,就按 3 周做,而不是 21 天.
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.
这篇关于查询以获取超过 3 周的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!