提醒篇--增加學(xué)員生日提醒
2012年03月15日 05:53
點擊率:11894
|
首先我們先參考數(shù)據(jù)庫字典寫一條提醒,找到學(xué)員表Student里的生日字段Birthday,然后我們使用sql語法編寫查詢語句: Select StudentID as 學(xué)號, StudentName as 姓名 from Student where Birthday is not null and Datepart(month, Birthday) = Datepart(month, getdate()) and Datepart(day, Birthday) = Datepart(day, getdate())
這個查詢是針對sql數(shù)據(jù)庫版的。 然后就可以增加提醒了,在系統(tǒng)-系統(tǒng)提醒-新建,按下圖所示把語法填寫好: 完整的語法: 標 題:生日提醒 提示消息:今天有{0}名學(xué)員過生日了 數(shù)量查詢: 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 學(xué)號, 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}名學(xué)員過生日了 ,括號里的是數(shù)字零。 2.數(shù)量查詢和展開查詢略有區(qū)別。
這樣在系統(tǒng)首頁,我們就可以看到提醒了。
上面講的是sql數(shù)據(jù)庫版的語法,Access數(shù)據(jù)庫版語法只需要改動兩個參數(shù)即可,如下圖:
完整的語法: 標 題:生日提醒 提示消息:今天有{0}名學(xué)員過生日了 數(shù)量查詢: 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 學(xué)號, StudentName as 姓名 from Student where Birthday is not null and DATEPART('M', Birthday) = DATEPART('M', now()) and DATEPART('d', Birthday) = DATEPART('d', now())
|