VB.NET MS Access DATEADD ..帮助!!! [英] VB.NET MS Access DATEADD.. Help!!!
问题描述
当我进入表适配器(VB.NET)的查询生成器,并添加以下代码时,我不断收到错误:
代码:
Hi,
When I go into the Query Builder of my Table Adapter(VB.NET), and add the following code, I keep getting errors.:
Code:
SELECT CPR, FName, LName, CPRIdt, CPREdt, nation, Gender
FROM Emp_master
where CPREdt>= date() and CPREdt<= dateadd(day , 15 ,date())
我想在日期之间找到记录:今天和提前15天。
例如:说我有2条记录在哪里CPREdt是12/15/2013和12/18/2013。
假设今天为2013年12月1日,查询必须返回15中的所有值天期。这意味着必须返回CPREdt 15/15/2013的记录。
我尝试使用上面的代码(用getdate()替换date())然后成功使用MS SQL Express 2008。我目前正在使用MS Access作为这个项目的数据库。
如果有人能帮助我,我真的很感激。谢谢!
I want to find the records only between the dates: today and 15 days ahead.
For example: say I have 2 records where the CPREdt is 12/15/2013 and 12/18/2013.
Assuming today as 12/1/2013, the query must return all the values within the 15 days period. Which means the record with the CPREdt 15/15/2013 must be returned.
I tried with the above code (replacing date() with getdate()) and it worked with MS SQL Express 2008 successfully. I am currently using MS Access as the database for this project.
I would really appreciate if anybody can help me. Thanks!
推荐答案
这将起作用我认为
This will work i think
SELECT CPR, FName, LName, CPRIdt, CPREdt, nation, Gender
FROM Emp_master
where CPREdt>=Date() and CPREdt <= Date() + 15
哇!最后我找到了这个错误的解决方案。事实证明它是来自'Mike Meinz'和'karthikeyan_kk 730'的查询语句的组合。
代码:
Wow! Finally I found the solution to this error. As it turns out it was a combination of the query statements from 'Mike Meinz' and 'karthikeyan_kk 730'.
Code:
SELECT CPR, FName, LName, CPRIdt, CPREdt, nation, Gender
FROM Emp_master
WHERE (CPREdt >= now) AND (CPREdt <= now + 15)
事实证明,'now'函数是Access作为当前DateTime的函数。添加额外的天数就像'now + 15'。我将Mike现在功能的想法变成了karthikeyan的代码,瞧,它就像一个魅力。
非常感谢'Mike Meinz'和'karthikeyan_kk 730'为了你的指导。
问候。
As it turns out, the 'now' function is what Access takes as the current DateTime. Adding additional days would be simply like 'now+15'. I implemented Mike's idea of the now function into karthikeyan's code and voila, it works like a charm.
Thank you very much to 'Mike Meinz' and 'karthikeyan_kk 730' for your guidance.
Regards.
这篇关于VB.NET MS Access DATEADD ..帮助!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!