0
SELECT DISTINCT    
d.name AS "ID:Link/Demo Request:120",    
d.requester_name AS "Requester Name:Data:190",    
d.customer_name AS "Customer Name:Data:250",    
d.date_of_request AS "Date Of Request:Date:120",    
d.tentative_date_of_return AS "Tentative Date Of Return:Date:170",    
d.material_sent_from_location AS "Material Sent From Location:Data:190",    
d.delivery_note AS "Delivery Note:Data:100",    
d.material_status AS "Material Status:Data:120",    
d.product_supplied_condition AS "Product Supplied Condition:Data:150",    
d.courier_service AS "Courier Service:Data:120",    
d.shipped_date_from_rahi AS "Shipped Date From Rahi:Date:120",    
d.tracking_no AS "Tracking No:Data:120",    
DATEDIFF(now(),d.tentative_date_of_return) AS "No Of Days:Data:100"

FROM    
`tabDemo Request` as d

WHERE    
d.material_status not like "Recieved From Customer"    
AND    
DATEDIFF(now(),d.tentative_date_of_return) <= now() + 3

ORDER BY d.tentative_date_of_return ASC
  • What is the datatype of tentative_date_of_return? – Rick James Oct 23 at 5:05
  • AND DATEDIFF(now(),d.tentative_date_of_return) <= now() + 3 DATEDIFF gives you a small INTEGER as a difference. You try to compare it with expression. In this expression the datetime of NOW is converted into DECIMAL with the value over 2*10^14 for addition (see Conversion Between Date and Time Types). So the result will be always TRUE. – Akina Oct 23 at 5:36
1

You want

AND d.tentative_date_of_return <= CURDATE() + INTERVAL 3 DAY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.