开发者

Selecting records by date and time

i am having trouble with a select statement on a table (mysql) and no clue 开发者_开发技巧what the right solution could be. It looks quite simple. I am having a couple of records representig a flightlog. There is a field like date, which is the day of the flight an a field named time which is for example the landing time. Now i would like to select all flights before or in a range of particular dates an times to build up a sum of flighthours.

Eventually what i need is to get the actual flighthours summed up to a particular record to be identified by the day of flight and the landingtime.

My first attempt was like this

select * from flights where date < "2010-01-01" and landing <= "14:30";

But everybody knows (even me now) that this is only displaying records where the landingtime is less or equal "14:30" regardless of the day of flight.

Anybody here able to help me?

Many thx

cdjw


Date fields are comprised of date and time. Combine the two. Then say where date between "2010-01-01 00:00:00" and "2010-01-01 14:30:00" (you know, however you'd format the dates to make that work.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜