简体   繁体   English

查询日期大于60天的记录

[英]Query records with date greater than 60 days

I am trying to query all records that have a date that is greater than 60 days of its created date and also has a null value in another field "Invoice#" The "Date_Created" field is saved as a date in YYYY-MM-DD. 我正在尝试查询日期大于其创建日期的60天并且在另一个字段“ Invoice#”中也为空值的所有记录。“ Date_Created”字段保存为YYYY-MM-DD中的日期。 This is currently hat I am using but doesn't seem to be working. 我目前正在使用这顶帽子,但似乎没有用。 I get an error saying "Invoice_Number" is an unknown column and when I remove that part of the code I get nothing returned. 我收到一个错误消息,说“ Invoice_Number”是一个未知列,当我删除那部分代码时,我什么也没得到。

select * from PO_Information where Date_Created >= (Date_Created + Interval 60 day) and Invoice_Number IS NULL 从PO_Information中选择*,其中Date_Created> =(Date_Created +间隔60天)且Invoice_Number为NULL

WHERE Date_Created >= DATE_ADD(Date_Created,INTERVAL 60 DAY)

For the interval, but This will always return false, this is why you are getting no results when you remove the IS NULL 对于间隔,但这将始终返回false,这就是为什么在删除IS NULL时没有任何结果的原因

as for the unknown column, you have not told us about the table structure so I can't help you there 至于未知列,您没有告诉我们表结构,所以我不能帮您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM