SQl的时间问题。(75分)

  • 主题发起人 主题发起人 LongHai
  • 开始时间 开始时间
L

LongHai

Unregistered / Unconfirmed
GUEST, unregistred user!
我想得出某段时间之内的记录SQL如下:
SELECT * FROM TABLE1 WHERE WRITEDATE BETWEEN '2002-11-05 01:01:01' AND 
'2002-11-05 23:59:59'
我想选出2002-11-05日的记录,那上面的SQL选不出2002-11-05日的记录,有没有什么
解决方法(这句SQL可以运行,就是结果为空)
 
确定有满足条件的记录吗?如果要查一天的记录应该从开始吧
SELECT * FROM TABLE1 WHERE WRITEDATE >='2002-11-05 00:00:00' AND 
WRITEDATE <='2002-11-05 23:59:59'
试试
 
SELECT * FROM TABLE1 WHERE WRITEDATE>='2002-11-05 00:00:00' AND 
WRITEDATE<='2002-11-05 23:59:59'
或者
SELECT * FROM TABLE1 WHERE Year(WRITEDATE)=2002 AND Month(WRITEDATE)=11 AND
Day(WRITEDATE)=05 
 
你用的是什么数据库,如果是ACCESS,要这么改一改:
SELECT * FROM TABLE1 WHERE WRITEDATE BETWEEN '#2002-11-05 01::01::01#' AND 
'#2002-11-05 23::59::59#'
 
year(writedate)='2002' and month() = and day()=
 
请相信我:
SELECT * FROM TABLE1 WHERE WRITEDATE>'2002-11-04 23:59:59' AND 
WRITEDATE<'2002-11-06'
good luck!
 
SELECT * FROM TABLE1 WHERE WRITEDATE BETWEEN convert(smalldate,'2002-11-05 01:01:01') AND 
convert(smalldate,'2002-11-05 23:59:59')
 

Similar threads

D
回复
0
查看
911
DelphiTeacher的专栏
D
D
回复
0
查看
868
DelphiTeacher的专栏
D
D
回复
0
查看
840
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部