有人知道在access数据库中如何用sql语句查询日期吗? (10分)

J

jcjy

Unregistered / Unconfirmed
GUEST, unregistred user!
有人知道在access数据库中如何用sql语句查询日期吗?
比如要按年查出生年月是:按年查询1998年的记录,按月查询9月的记录,按日查询15日的记录。
 
我一般是把日期转成字符串,然后再用SQL查询。但要注意格式问题。
 
select fieldName from tableName where Birthday = #1998-09-19#
 
select * from SomeTbl where m_Birth = '1998-9-19'
 
同意tseug的意见,我这么是可能做出来的,
不过我现要分年月日查询出是1998年出生或9月出生的或15日出生的记录,怎么做呢?
 
select * from table1 where birth between #1998-01-01# and #1998-12-31#
 
to naughtboy
这样做也只是查出了一年有记录呀。如果是一月的,是不是我还要判断是不是28天,29天,30天,31天呀?
 
year(birth)=1998 and month(birth)=5 等等!!
 
select * from table where year(birth)=1998 and month(birth)=9 and day(birth)=15
 
谢谢各位,根据大家所说和我的调试,我得出正确答案:
select * from 学籍基本信息表 where year(出生年月)='1995' and month(出生年月)='4'
特别感谢番番,并送分。
 
顶部