asp 查询今天所有过生日的人?

来源:百度知道 编辑:UC知道 时间:2024/07/05 07:22:01
比如今天是9月2号,我要把数据库里所有出生日期是9月2号的人取出来该怎么办。数据库的事情是2009-9-2这样的格式
是access数据库
select * from NK_kehu where format(Birthday,'mm-dd')=#9-3# order by Id desc
或者
select * from NK_kehu where format(Birthday,'mm-dd')='9-3' order by Id desc
完全查询不到呢
明白了,谢谢!

没有那么麻烦一个语句搞定。请确认生日列是日期类型。

SELECT *
FROM user where format(user.Birthday,'mm-dd')='09-02'

access自己有很多内置的函数,都可以使用。干吗非要局限于标准的sql,用format函数就好了。
-----------------------------------------------------------------
你写错了,要用09-03 因为前面format的格式是mm-dd,双数字的日期格式
你要用9-3 需要修改m-d
select * from NK_kehu where format(Birthday,'mm-dd')='09-03' order by Id desc
或者
select * from NK_kehu where format(Birthday,'m-d')='9-3' order by Id desc
肯定是对的。

<%
Birthday="1990-9-2 07:10:33" ' 数据库取出日期
Birthdays=FormatDateTime(Birthday,2) ' 格式化取出日期
today=FormatDateTime(date(),2) ' 格式化当前日期

n=Instr(Birthdays,"-")
m=len(Birthdays)
Birthdays=Right(Birthdays,m-n)

i=Instr(today,"-")
j=len(today)
today=Right(today,j-i)

if Birthdays=today the