我有一个来自 MS Excel 2007 的公式,它返回特定月份内特定日期的工作周。
B1 = IF(AND(WEEKDAY(A2,1)<>1,A2=DATE(YEAR(A2),MONTH(A2),1)),A2-WEEKDAY(A2,1)+7,IF(MONTH(A2)<>MONTH(A2-WEEKDAY(A2,1)+7),EOMONTH(A2,0),A2-WEEKDAY(A2,1)+7))
其中 A1 = 11/2012
且 B1 = 1/7/2012
我想在 MS Access 中使用此公式并将返回相同的值。我尝试编写一个查询,但行不通。
A1 列的字段名称为 [rdate],B1 列的字段名称为 [we_date]。
最佳答案
不要计算,要查询。请参阅:
Why should I consider using an auxiliary calendar table?
A calendar table can make it much easier to develop solutions around any business model which involves dates. Last I checked, this encompasses pretty much any business model you can think of, to some degree. Constant problems that end up requiring verbose, complicated and inefficient methods include the following questions:
- How many business days between x and y?
- What are all of the dates between the second Tuesday of March and the first Friday in April?
- On what date should I expect this shipment to arrive?
- What were the dates of all the Fridays in this quarter?
- ...
关于sql - 在 Access SQL 中查询 "workweek",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9094847/