要实现对时间字段的四种查询(= ,<,>, <>)
我的语句是这样的
If ComboSerTime.Text = "!=" Then
   searchSQL = "select * from works where train_time<>'" & Trim(TextSerTime.Text) & "'"
  End If
  Adodc3.RecordSource = searchSQL
Adodc3.Refresh
这个通过在ComboSerTime中选择查询条件(= ,<,>, <>)在TextSerTime中输入时间(SMALLDATETIME格式的)
但查询冒得么反映!会是么问题啊?
…………………………………………
有哪个函数可以判断Text框内输入的是否为时间格式,如果是再用哪个函数将其转换为SMALLDATATIME类型的咧!

解决方案 »

  1.   

    CAST('2006-10-26' AS smalldatetime)
      

  2.   

    可以写得更清楚一些吗?
    报错了,在MSDN里没有找到这个函数啊
      

  3.   

    CAST('2006-10-26' AS smalldatetime)
    //这是sql的函数
    判断是不是日期可以用isdate()返回对错
      

  4.   

    select * from works where Case(train_time as Smalldatetime)<>'" & Trim(TextSerTime.Text) & "'
      

  5.   

    那是不是改那个语句为这样的咧?
    searchSQL = "select * from works where train_time<>'" & Trim(CAST(TextSerTime.Text AS smalldatetime)) & "'"
      

  6.   

    select * from works where Cast(train_time as Smalldatetime)<>'" & Trim(TextSerTime.Text) & "'
      

  7.   

    还是不行咧
    报的错是Unknow Error
    又指向是Adodc3.Refresh出问题了
      

  8.   

    searchSQL = "select * from works where train_time<>CAST('" & Trim(TextSerTime.Text) & "' AS smalldatetime)"
      

  9.   

    用datediff作
    select * from works where datediff(day,train_time,'"& TextSerTime.Text &"')<>0
    看看可以不 是sql server 2k吧?
    datediff(day,train_time,'"& TextSerTime.Text &"')返回train_time距离TextSerTime.Text 的天书
      

  10.   

    感觉楼主用的是access
    searchSQL = "select * from works where train_time<>#" & Trim(TextSerTime.Text) & "#"
    这样看看