MS Access: get the array of dates which are located in the range start_date to end_date

后端 未结 1 1613
北荒
北荒 2021-01-27 07:18

MS Access 2003.

I need to get the array of dates which are located in the range start_date to end_date. I not found such function in standard set of MS

1条回答
  •  别那么骄傲
    2021-01-27 07:52

    You are getting errors because your VBA function is returning an array of Date values but the Access Database Engine does not have an Array field type. Even if it did, you would wind up with a single row containing an array of dates and (according to the comments to the question) you want each date in a separate row.

    You should be able to accomplish your goal without using VBA at all if you create a "Numbers" table with sequential integer values from 0 to a sufficiently large value, e.g.,

       n
    ----
       0
       1
       2
       3
    ...
     998
     999
    1000
    

    and then use a query like this:

    SELECT DateAdd("d",n,#2014-01-01#) AS DayItem 
    FROM Numbers 
    WHERE n <= DateDiff("d",#2014-01-01#,#2014-01-05#)
    

    returning

       DayItem
    ----------
    2014-01-01
    2014-01-02
    2014-01-03
    2014-01-04
    2014-01-05
    

    0 讨论(0)
提交回复
热议问题