zjcxc(邹建)老大。数据库为ACCESS,字段样式为:2004-5-5时间格式,查询如何作。
1 我想查询出所有从2004年11月4日到2005年1月3日的数据,如何查询?
2 还有如何查询出所有为2004-4-4日的数据呢?
3 如何查询出所有2004年4月的数据呢?
数据库为ACCESS。
问题点数:50、回复次数:3Top
1 楼chly1010(云淡风清)回复于 2005-01-27 08:00:07 得分 0
SELECT * FROM table where datediff("d",date1,"2004-12-6")=0; 按照天查询
SELECT * FROM table where datediff("m",date1,"2004-12-6")=0; 按照月查询
Top
2 楼j9968(j9968不是J9868也不是J9898更不是J9988)回复于 2005-01-27 08:35:21 得分 0
1. select * from tablename where DateField between #2004-11-4# and #2005-1-3 23:59:59.999#
2. select * from tablename where datediff("d",DateField,#2004-4-4#)=0
3. select * from tablename where datediff("m",datefield,#2004-4-1#)=0
Top
3 楼zjcxc(邹建)回复于 2005-01-27 09:06:04 得分 50
--1 我想查询出所有从2004年11月4日到2005年1月3日的数据,如何查询?
select * from tablename where format(DateField,"yyyy-mm-dd") between "2004-11-04" and "2005-01-03"
--2 还有如何查询出所有为2004-4-4日的数据呢?
select * from tablename where format(DateField,"yyyy-mm-dd" )="2004-04-04"
--3 如何查询出所有2004年4月的数据呢?
select * from tablename where format(DateField,"yyyy-mm" )="2004-04"
Top




