Jump to content

Archived

This topic is now archived and is closed to further replies.

bryan11

Query to select single date from datetime field

Recommended Posts

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' ?

Share this post


Link to post
Share on other sites
Provided you have a recent version of MySQL, use DATE(Orders.ShipDate) = '2006-07-25'.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.