要实现对时间字段的四种查询(= ,<,>, <>)
我的语句是这样的
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类型的咧!
我的语句是这样的
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类型的咧!
报错了,在MSDN里没有找到这个函数啊
//这是sql的函数
判断是不是日期可以用isdate()返回对错
searchSQL = "select * from works where train_time<>'" & Trim(CAST(TextSerTime.Text AS smalldatetime)) & "'"
报的错是Unknow Error
又指向是Adodc3.Refresh出问题了
select * from works where datediff(day,train_time,'"& TextSerTime.Text &"')<>0
看看可以不 是sql server 2k吧?
datediff(day,train_time,'"& TextSerTime.Text &"')返回train_time距离TextSerTime.Text 的天书
searchSQL = "select * from works where train_time<>#" & Trim(TextSerTime.Text) & "#"
这样看看