我目前的代码是这样:Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier])我的问题是Year(Now())作为无效表达式返回.许多网站已经认识到使用Now()函数,并且我也尝试过使用Date(),但是Access似乎没有接受任何东西(版本为2010).这是怎么回事?如何在计算出的字段表达式中获取今天的日期?谢谢解决方案尝试使用表中的所有字段创建查询,然后添加一个额外的字段YearGroup: Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier]) 似乎Date函数不能在表中的计算列中使用.Hi I am creating a table in MS Access to store the details of children in a school. I have a field called YearGroup which needs to calculate the school year they are in based on their date of birth and whether they have been moved up or down a year. I.e. if the expression deems they are six years old they should be placed in year 2. If they were moved down or up a year they should be in year 1 or 3 (this is based on another field in the table called YearModifier).The code I have at the moment is this:Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier])My problem is that Year(Now()) is returning as invalid expression. Lots of websites have recognised using the Now() function and also I've tried Date() but nothing seems to be accepted by Access (The version is 2010).What is going on? How can I get today's date in a calculated field expression?Thanks 解决方案 Try creating a query with all of the fields from your table, and then add an extra field YearGroup: Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier])It appears that Date functions can't be used in calculated columns in tables. 这篇关于MS Access:在计算的字段表达式中处理今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 15:17