1、数据表中字段 publishedtime记录了信息的发布时间。(Access表)如何得到 所有的,今天发布的信息? 在SQLSERVER2000中,下面写法是对的。如果数据表是ACCESS,就不知如何改了?sql = "select  * from systemdata  where (DATEDIFF(dd, publishedtime, GETDATE()) = 0)  order by id desc"我试着写:   thisdate:= Date();
   todayado.SQL.Text:='Select  * From systemdata  where  (DATEDIFF(dd, publishtime, thisdate) = 0)   order by id     ';不行。
===========================2、如果 用户根据 DateTimePicker控件选择了两个日期段,如何用SQL语句,输出所有的,这个日期段内的记录啊?(数据表分别是SQLSERVER和ACCESS)
SQL=' select * from  systemdata where 日期1 到 日期2  '谢谢!

解决方案 »

  1.   

    1. SELECT * from systemdata where datediff("d",publishtime,date()) = 0
    2.sql : SELECT * from systemdata where publishtime between '2008-1-1' and '2008-1-1 23:59:59'
     access : SELECT * from systemdata where publishtime between #2008-1-1# and #2008-1-2#
      

  2.   


    todayado.sql.clear;
    todayado.SQL.add('Select  * From systemdata  where  publishtime>=:date1 and publishtime <=:date2 order by id')
    todayado.Parameters.Items[0].Value:=Date1.DateTime;
    todayado.Parameters.Items[1].Value:=Date2.DateTime;
    todayado.open
    用这种方法你以上提的两种问题都可以实现,如果是当天就是date1的date2都是当天,这种方法在access下测试ok
      

  3.   

    刚才少写个分号,重新贴//用这种方法你以上提的两种问题都可以实现,如果是当天就是date1的date2都是当天,这种方法在access下测试ok
    todayado.sql.close;
    todayado.sql.clear;
    todayado.SQL.add('Select  * From systemdata  where  publishtime>=:date1 and publishtime <=:date2 order by id')
    todayado.Parameters.Items[0].Value:=Date1.DateTime;
    todayado.Parameters.Items[1].Value:=Date2.DateTime;
    todayado.open;
      

  4.   

    第二个不对。     todayado.SQL.add('Select  * From CjSystem  where  处理时间>=:date1 and 处理时间<=:date2 order by 车号')  ;
         todayado.Parameters.Items[0].Value:= temptoday;
         todayado.Parameters.Items[1].Value:= temptoday;
       todayado.Open;     //执行sql 返回结果,要用.open我这样写了,但按提示: 标准表达式中数据类型不匹配
      

  5.   

    var
      Form2: TForm2;
      temptoday:TDate;
     
    temptoday:=Date();       //获取当前日期