如何在两个日期之间从Sql中的表中获取记录

时间:2014-03-29 12:40:56

标签: mysql sql

如何从表中获取记录?但只有added_on >= '2014/03/01'added_on <= '2014/03/31'

的记录

目前我的sql表字段值为added_on = 2014/03/29 05:23:43

请尽快帮助我

3 个答案:

答案 0 :(得分:1)

简单的SQL查询

select * from table_name where (added_on between '2014-03-01' and '2014-03-31' );

您可能还想指定hh:mm:ss

select * from table_name where (added_on between '2014-03-01 00:00:00' and '2014-03-31 00:00:00' );

两者都应该有用。 :)

答案 1 :(得分:0)

SELECT *
FROM [table]
WHERE CONVERT(datetime, [added_on]) between '2014/03/01' AND '2014/03/31'

答案 2 :(得分:0)

试试这个

SELECT * 
FROM `table_name` 
WHERE DATE(added_on) BETWEEN '2014/03/01' AND '2014/03/31'