select sum(studychj) as tofflinejz from afterline where checkflag=1 and studytype=1 and studybegin>='2010-01-01 00:00:00' and studyend<='2010-12-01 00:00:00' and username='01009' 這么寫不報錯,但得出結果不准確 方法一: 你也可以: select * from t1 where unix_timestamp(time1) > unix_timestamp('2011-03-03 17:39:05') and unix_timestamp(time1) < unix_ timestamp('2011-03-03 17:39:52'); 就是用unix_timestamp函數,將字符型的時間,轉成unix時間戳。個人覺得這樣比較更踏實點兒。 方法二: time1 between '2011-03-03 17:39:05' and '2011-03-03 17:39:52'; 方法三: 可以講datetime類型轉換成date類型再進行比較 例如:convert(date,表名.datetime列名) >= convert(date,表名.datetime列名) 三種方法待求證,總之是不要用字符串這么直接比