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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to combine both separate date and time fields ?

Status
Not open for further replies.

newtomysql

Technical User
Apr 11, 2001
96
MY
Dear All,
I have a table where I keep separately the data and time information in 2 separate columns. My problem come like this query

select * from tbltransfer where transferFromDate>='2009-01-30' and transferFromTime>='13:00:00' order by transferFromDate.
What I get is all those transfer which have data equal to '2009-01-30' which is correct but it also search all those time which is transferFromTime>='13:00:00'. So the problem here is that for instance I have a transferdate on '2009-02-02' and transferTime on '09:00:00' so this search result doesnt appear any solution please ? Thanks.
 
ur dataSet for time only hold values that are resulting from FromDate so you can do this;

select * from xx where FromTime>='blah' or (FromData=>'blah' and FromTime>='blah');
 
Dear Max,
I have tried your method it doesnt solve my problem it gives me the same results and even more results with all those more than the timing but not more than the state date.
 
Code:
SELECT * 
  FROM tbltransfer 
 WHERE transferFromDate > '2009-01-30'
    OR ( transferFromDate = '2009-01-30' 
         AND transferFromTime >= '13:00:00')

 ORDER BY transferFromDate, transferFromTime

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top