Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Search Date (now) in Specific time

I want to search a Date (now) like 2022-04-11 in specific time like 00:00:00. and in this code showing date & time 0000-00-00 00:00:00.

SELECT Process_Date, Product_Number, COUNT(*) AS TEST FROM tb_main WHERE Process_Date = DATE_FORMAT(NOW(), '00:00:00') GROUP BY Product_Number;

i’ve already tried this code but syntax was error.

CURDATE(), '00:00:00'

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to use DATE_FORMAT to get midnight of the current date, then you need a format mask for the entire timestamp:

SELECT Process_Date, Product_Number, COUNT(*) AS TEST
FROM tb_main
WHERE Process_Date = DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00')
GROUP BY Product_Number;

You could also use the TIMESTAMP function here:

SELECT Process_Date, Product_Number, COUNT(*) AS TEST
FROM tb_main
WHERE Process_Date = TIMESTAMP(CURRENT_DATE)
GROUP BY Product_Number;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading