Access 2007 Days served in a fiscal year

A lot of my data mutilation involves dates and duration around services that a client receives. My issue is that when a client services cross over into different fiscal years.  I need to show how many days client received services in each fiscal year.  

Example of fiscal year:  FY13:  7/1/2012 - 6/30/2013
                                      FY12: 7/1/2011 - 6/30/2012

example of a client date of service: 5/14/2012 - 8/14/2012

Total days of service is 91

I need to break the days of service in FY that was served.

Days in FY12 should be : 47

Days in FY13 should be : 44
Who is Participating?
Gustav BrockCIOCommented:
You can use these expressions:

? DateDiff("d", #5/14/2012#, #8/14/2012#)

? DateDiff("d", #5/14/2012#, DateFinancialFirst)

? DateDiff("d", DateFinancialFirst, #8/14/2012#)

Public Function DateFinancialFirst() As Date
  Dim datFin    As Date
  Dim datNow    As Date
  Dim datFirst  As Date

  datNow = Date
  datFin = DateFinancial(datNow)
  datFirst = DateSerial(Year(datFin), 1 - DateDiff("m", datNow, datFin), 1)
  DateFinancialFirst = datFirst

End Function

Public Function DateFinancial( _
  ByVal datDate As Date) _
  As Date
  ' Number of months from start of calendar year to start of financial year.
  Const clngMonthOffset As Long = 6
  Dim datFinancial      As Date
  datFinancial = DateAdd("m", -clngMonthOffset, datDate)
  DateFinancial = datFinancial
End Function

Open in new window

Jeffrey CoachmanMIS LiasonCommented:
As a start, you should have a "FiscalYears table:

FiscalYearID (Primary Key)
FiscalYearStartDate (Date/Time)
FiscalYearEndDate (Date/Time)
FiscalYearDays (number) (possibly optional if the days are "calculated")

You will have to post more info about how the service daya are determined though...
...and also tell us about any invalid date or date ranges...

In other words, post an example of some data (for all contingencies) and the exact results you are looking for, based on the sample data.

Jeffrey CoachmanMIS LiasonCommented:
...or better yet, just post a sample of this database...

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide and hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

jbakestullAuthor Commented:
Gustav BrockCIOCommented:
You are welcome!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.