0

I have an .asp script that runs the following SQL statement;

set rstmp = CustomQuery("select * from SysRes_Master where DATEDIFF(day, GETDATE(), DateChkIn)<1")

What this returns on the webpage is any record with a date in the "DateChkIn" field that is older then the days date (current). However, if this field is blank that record is also returned.

How can I modify this so that is still returns the expired record but ignores any records with a blank in the same?

4

2 回答 2

0

根据 DateChkIn 的属性,

set rstmp = CustomQuery("select * from SysRes_Master where DATEDIFF(day, GETDATE(), DateChkIn) < 1 AND DateChkIn > 0")

或者

set rstmp = CustomQuery("select * from SysRes_Master where DATEDIFF(day, GETDATE(), DateChkIn) < 1 AND DateChkIn IS NOT NULL")
于 2013-04-18T20:10:48.157 回答
0

我真的会考虑在你的选择中选择你想要的字段,获得比需要更多的数据是性能调整的第一件事,

如果我正确理解您的问题,您的问题是您也获得了 DateChkln 字段,因此选择您想要的字段应该过滤掉其他字段

如果您有多个带有日期的字段,您可以使用检查空值的合并(谷歌它)

你有什么数据库?mysql?,windows?

于 2013-04-18T19:27:16.010 回答