房间号  预住          预离
102   05-12-25 08:00   05-12-27 18:00 
105   05-12-26 08:00   05-12-27 17:00 
102   05-12-29 08:00   05-12-30 17:00 我想找出规定时间段,比如(05-12-26 07:00至05-12-30 17:00)有预订入住的房间号

解决方案 »

  1.   

    query.close;
    query.sql.text:='select 房间号 from 旅馆 where 预住>=''aaa'' and 预离<=''BBB'' ';
    qurey.open;//注意 1:   因为datetime数据其实是double型,所以可以比较
           2:   aaa,bbb 两边双引号表示这是字符型,后台数据库会处理这个的
      

  2.   

    很简单的吧
    query.close;
    query.sql.text:='select 房间号 from 旅馆 where 预住>= '+
                    QuotedStr(dp1.dateTime)+ ' and 预离<= '+QuotedStr(dp2.dateTime);
    qurey.open;