Solved

Table Development question

Posted on 2014-09-03
6
172 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 50

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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 50

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

752 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