range of datetime data type (show all records in between 2 dates. example: form
2008/10/01 to 2008./12/12). thanks

If the data type is datetime, then you must include time in the query

SELECT * FROM table where date_col BETWEEN '2008-10-01 00-00-00' AND '2008-12-12 23:59:59'

I need help please with a similar issue but in my case I don't want a specific date.

I need to query all records created yesterday.

Since the get date function only finds records with the exact minute and second I need to use a range. Less than current date but greater than 23 hours 59 minutes old.

How can I write this query please?

THank you

Matthew

If the data type is datetime, then you must include time in the query

SELECT * FROM table where date_col BETWEEN '2008-10-01 00-00-00' AND '2008-12-12 23:59:59'
SELECT * FROM table WHERE date_col<curdate() and date>DATE_ADD(CURDATE(), INTERVAL -1 DAY)

Thank you very much for your help.

I was able to solve it in fact with datediff(date_col,getdate()) = -1

We are running mssql

Best regards,

Matthew

SELECT * FROM table WHERE date_col<curdate() and date>DATE_ADD(CURDATE(), INTERVAL -1 DAY)

make this thread as solved...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.