Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax for date query

Status
Not open for further replies.

shamrox

Programmer
Sep 27, 2001
81
US
I am creating a search form that would give a list of records based on a start and end date. What would be the syntax for the query?

This is what I thought it might be...but doesn't seem to work.
SELECT *
FROM employee_time
WHERE `date` >= 'starttime' and 'date' <= 'endtime' and eid = 'analyst'



 
actually I'm having almost the same confuse problem here.

till now i've tried 2 methods for my query dealing with date range.
I'm trying in 2 computer machine which i install the same version MySQL 4.0.21. In one machine i got false return, but at the other one i got the correct ones.
perhaps my found would help you.

this query syntax is inconsistable in my 2 machines
Code:
Select * from Table1 Where date_format(receiptdt, '%Y-%c-%d') = '2004-1-1' 
and date_format(receiptdt, '%Y-%c-%d') = '2004-9-24';

then i change the query into what you can see below (it gives correct returns in 2 machines):
Code:
Select * from Table1 Where receiptdt = '2004-1-1 00:00:00' 
and receiptdt = '2004-9-24 23:59:59' ;


any one can help me explain what's wrong with my 2 machine??
is there anything connecting to regional setting of these machines when i install MySQL ??

thanks
*JJ*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top