bryan11 Posted September 12, 2006 Share Posted September 12, 2006 I've been searching records using ranges of dates with this kind of select statement:select * from Orders where Orders.BillName="Village Pantry" and Orders.ShipDate >= '2006-07-25';Orders.ShipDate is a datetime field. Now I need to select rows from an exact date, but this doesn't yield any results though many rows exist with this date:select * from Orders where Orders.BillName="Fred's" and Orders.ShipDate = '2006-07-25';I tried several variations on this and the results got weird. For example, using the following query I get dates from 7/24/06 to 7/25/06:select * from Orders where Orders.BillName="Fred's" and Orders.ShipDate < '2006-07-26' and Orders.ShipDate > '2006-07-24' and Orders.QuickBooks != '' order by Orders.ShipDate;How may I select records only for '2006-07-25' ? Quote Link to comment https://forums.phpfreaks.com/topic/20559-query-to-select-single-date-from-datetime-field/ Share on other sites More sharing options...
fenway Posted September 12, 2006 Share Posted September 12, 2006 Provided you have a recent version of MySQL, use DATE(Orders.ShipDate) = '2006-07-25'. Quote Link to comment https://forums.phpfreaks.com/topic/20559-query-to-select-single-date-from-datetime-field/#findComment-90722 Share on other sites More sharing options...
bryan11 Posted September 12, 2006 Author Share Posted September 12, 2006 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/20559-query-to-select-single-date-from-datetime-field/#findComment-90726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.