Solved

Table Development question

Posted on 2014-09-03
6
173 Views
Last Modified: 2014-09-04
Experts, I am developing a table but need a little help.  

I have :
ID
[Description]
[Type]
[WithinDays]
[Type]

I have many reporting requirements and they are either Quarterly, Semiannually, Annually and within a certain number of days past those points.  For example, an annual report would be within 120 days after years end and a quarterly is within 60 days past the quarter.  

My question is, do I hard code [withindays] (ie 120, 60) as a field in a table?  Or is it better some other way (maybe within a query)

thank you
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
Priya Sudharsan earned 250 total points
ID: 40302667
Do not hard code it. Have the data alone in the table and build queries as per the reporting criteria for each reports.
0
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 40302929
That would be an Integer. Then you can use DateAdd and DateDiff to find dates or calculate day passed relative to, say, quarter end or quarter start.

To identify various parts of a year, this function can be helpful:
Public Function DatePartYear( _
    ByVal strInterval As String, _
    ByVal datDate As Date) _
    As Integer
    
' Returns the part of the year of datDate according to strInterval.
'
' 2008-02-07. Cactus Data ApS, CPH.
    
    Const cMonthsInYear As Integer = 12
    
    Dim intYearPart     As Integer
    Dim intYearParts    As Integer
    
    Select Case strInterval
        Case "y", "m", "q"
            ' Day, Month, or Quarter of a year.
            intYearPart = DatePart(strInterval, datDate)
        Case "i"
            ' Dimidiae. Half part of a year.
            intYearParts = 2
        Case "t"
            ' Tertia. Third part of a year.
            intYearParts = 3
        Case "x"
            ' Sexta. Sixth part of a year.
            intYearParts = 6
    End Select

    If intYearParts > 0 Then
        intYearPart = -Int(-Month(datDate) / (cMonthsInYear / intYearParts))
    End If

    DatePartYear = intYearPart

End Function

Open in new window

And to find, say, first or last date of a quarter, these can be used:
Public Function DateThisQuarterFirst( _
  Optional ByVal datDateThisQuarter As Date) As Date
  
  Const cintQuarterMonthCount   As Integer = 3
  
  Dim intThisMonth              As Integer
  
  If datDateThisQuarter = 0 Then
    datDateThisQuarter = Date
  End If
  intThisMonth = (DatePart("q", datDateThisQuarter) - 1) * cintQuarterMonthCount

  DateThisQuarterFirst = DateSerial(Year(datDateThisQuarter), intThisMonth + 1, 1)

End Function

Public Function DateThisQuarterLast( _
  Optional ByVal datDateThisQuarter As Date) As Date
  
  Const cintQuarterMonthCount   As Integer = 3
  
  Dim intThisMonth              As Integer
  
  If datDateThisQuarter = 0 Then
    datDateThisQuarter = Date
  End If
  intThisMonth = DatePart("q", datDateThisQuarter) * cintQuarterMonthCount
  
  DateThisQuarterLast = DateSerial(Year(datDateThisQuarter), intThisMonth + 1, 0)

End Function

Open in new window

Just examples.

/gustav
0
 

Author Closing Comment

by:pdvsa
ID: 40303216
thank you.  I plan to use those functions so I think a split is acceptable. Let me know if there is an objection.  

thanks again.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:pdvsa
ID: 40303471
Gustav:  could you give me a quick example of how I would use those functions?  Meaning I would first identify the end of quarter with the first function and then use DateADD to add X days?  I guess I would call the function in the query design window.  thank you for your help.  I am glad you responded.  I remember you are excellent with dates and technical questions.  I am a little rusty as have not worked in Access in some time.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40303573
You could ask:

"When is the next reports ultimo this quarter?"

    datNextThisQuarter = DateThisQuarterLast(Date)

"What is the deadline of this? If within 30 days:

    intMaxDelay = 30
    datNextThisQuarterLatest = DateAdd("d", intMaxDelay, DateThisQuarterLast(Date))

But there are, of course, many variations over this.

/gustav
0
 

Author Comment

by:pdvsa
ID: 40303938
very nice.  thank you.  I will be playing around with this.  thanks again for the codes.
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question