提醒篇--增加学员生日提醒

2012年03月15日 05:53
点击率:11428
首先我们先参考数据库字典写一条提醒,找到学员表Student里的生日字段Birthday,然后我们使用sql语法编写查询语句:
Select
StudentID as 学号,
StudentName as 姓名
from Student
where Birthday is not null
  and Datepart(month, Birthday) = Datepart(month, getdate())
  and Datepart(day, Birthday) = Datepart(day, getdate())

这个查询是针对sql数据库版的。

然后就可以增加提醒了,在系统-系统提醒-新建,按下图所示把语法填写好:
麦田培训学校管理软件细节

完整的语法:
标    题:生日提醒
提示消息:今天有{0}名学员过生日了
数量查询: 
Select
Count(*)
from Student
where Birthday is not null
  and DATEPART(month, Birthday) = DATEPART(month, getdate())
  and DATEPART(day, Birthday) = DATEPART(day, getdate()) 

展开查询:
Select
StudentID as 学号,
StudentName as 姓名
from Student
where Birthday is not null
  and DATEPART(month, Birthday) = DATEPART(month, getdate())
  and DATEPART(day, Birthday) = DATEPART(day, getdate())

这里需要注意的是:
1.提示消息:今天有{0}名学员过生日了 ,括号里的是数字零。
2.数量查询和展开查询略有区别。

    这样在系统首页,我们就可以看到提醒了。
麦田培训学校管理软件细节

上面讲的是sql数据库版的语法,Access数据库版语法只需要改动两个参数即可,如下图:
麦田培训学校管理软件细节

完整的语法:
标    题:生日提醒
提示消息:今天有{0}名学员过生日了
数量查询: 
Select
Count(*)
from Student
where Birthday is not null
  and DATEPART('M', Birthday) = DATEPART('M', now())
  and DATEPART('d', Birthday) = DATEPART('d', now()) 

展开查询:
Select
StudentID as 学号,
StudentName as 姓名
from Student
where Birthday is not null
  and DATEPART('M', Birthday) = DATEPART('M', now())
  and DATEPART('d', Birthday) = DATEPART('d', now())