RCustomerId GiftRegistryId ContactId DateActive DateExpire
----------- -------------- --------- ---------- ----------
62 66 225 NULL 2010-10-11
62 66 228 2010-10-13 NULL
62 67 229 NULL 2010-10-20
62 67 230 2010-10-21 NULL
62 68 232 NULL NULL 检查今天的日期是否为>=日期过期
如果它是>=,我想检查它是否为>=。
如果geater等于,则不需要显示contactid,否则显示contactid。
例如:
Consider today date id 2010-10-11
result is Contactid
228
229 发布于 2010-10-21 02:48:06
您可以尝试:
SELECT ContactId FROM TableName
WHERE GetDate() BETWEEN DateActive AND DateExpire您肯定需要对null日期使用ISNULL (我会将其包括在内,但根据您的问题,我不知道如何处理NULL值)。
发布于 2010-10-21 03:43:13
我想你想要的是
SELECT
contactid
FROM
yourtable
WHERE
dateactive >= '2010-10-11' OR dateactive IS NULL AND
dateexpire <= '2010-10-11' OR dateexpire IS NULL但这真的很难理解,抱歉。
https://stackoverflow.com/questions/3981167
复制相似问题