我表里定义了一个datetime类型的取货时间,现在我想把今天、明天、后天,三天的取货人数统计出来、和取货人的详细记录显示出来,而表里的取货时间是这样格式的2003-12-20 2:01:00,是带时间的,我怎样设置Adoquery的查询呢?

解决方案 »

  1.   

    怎样设置Adoquery的查询 //??
    你是说写sql语句来...
    'select 你要取的字段 from table where time字段 like'+quotedstr(now);
    'select 你要取的字段 from table where time字段 like'+quotedstr(tomorrow);Tomorrow returns a TDateTime value with the date portion set to the day following the current date and the time portion set to 0. 用like可不可以,我没有试过,听别人怎么说..
      

  2.   

    select * from table where left(time字段,10) >=date() and 
    left(time字段,10)<= dateadd(day,2,date())
      

  3.   

    是这样的一个BUTTON是显示今天,一个BUTTON显示明天,一个是后天,我就是不知道怎么查询
      

  4.   

    sql server数据库 可以用函数DateDiff(day,字段,GetDate())<2 and DateDiff(day,字段,GetDate())>-2
      

  5.   

    各位,我忘了高耸大家了,是ACCESS数据库,非常抱歉
      

  6.   

    select * from table where shijian>=date-1 and shijian<=date-1这样就ok了
      

  7.   

    select * from table where shijian>=date-1 and shijian<=date+1这样就ok了
      

  8.   

    select * from table where left(time字段,10) =date()   今天的取货人的详细记录
    select * from table where left(time字段,10) = dateadd(day,2,date())   后天的取货人的详细记录
    left('2003-12-20 2:01:00',10) 就是2003-12-20 
    date() 就是今天的日期 yyyy-mm-dd
    dateadd(day,1,date()) 就是明天的日期
    dataadd(day,2,date()) 就是后天的日期select sum(*) as 取货人数 from table where left(time字段,10) >=date() and 
    left(time字段,10)<= dateadd(day,2,date())  就是取货人数  够明白了吗
      

  9.   

    select * from table where datediff('d',date(),取货时间) = 0   // 今天
    select * from table where datediff('d',date(),取货时间) = 1   // 明天
    select * from table where datediff('d',date(),取货时间) = 2   // 后天
    select * from table where datediff('d',date(),取货时间) = -1  // 昨天
      

  10.   

    select 取货人,取货人数 from table where date:=now and date:=now+1 and date:=now+2