Create 4 Year Schedule

The following portion of my query shows columns that represent the first year of a 4 year report.

I will have four more sets of these columns that will reflect the count dates for the next three years.

How do I correctly calculate  the next three years?  
A parts are counted 2xs per year  - CountFREQ = 180
B parts are counted 1x per year -  countFreq =  365
C parts are counted every two years - countFreq = 730
D parts are counted every 4 years - countFreq = 1460

To get the next count date for the first year I add the count frequency to the last count date and I have a date.  

I'm not sure how to get the next three years of dates to show up correctly.


NEXT_Y1A1_COUNT =
CASE
WHEN P.ABC_CODE = 'A'
    THEN DATEADD(d, CCP.COUNT_FREQ, CCP.LAST_COUNT_DATE) END,

NEXT_Y1A2_COUNT =
CASE
WHEN P.ABC_CODE = 'A'
    THEN DATEADD(d, NEXT_Y3A1_COUNT, CCP.LAST_COUNT_DATE) END,


NEXT_Y1B_COUNT =
CASE
WHEN P.ABC_CODE = 'B'
    THEN DATEADD(d, CCP.COUNT_FREQ, CCP.LAST_COUNT_DATE) END,

NEXT_Y1C_COUNT = 
CASE
WHEN P.ABC_CODE = 'C'
   THEN DATEADD(d,CCP.COUNT_FREQ,CCP.LAST_COUNT_DATE)  END,

NEXT_Y1D_COUNT = 
CASE
WHEN P.ABC_CODE = 'D'
   THEN DATEADD(d,CCP.COUNT_FREQ,CCP.LAST_COUNT_DATE)  END,

Open in new window

Annette Wilson, MSISSr. Programmer AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
Just use a multiplier:
NEXT_Y1C_COUNT = 
CASE
WHEN P.ABC_CODE = 'C'
   THEN DATEADD(d,CCP.COUNT_FREQ*2,CCP.LAST_COUNT_DATE)  END,

NEXT_Y1D_COUNT = 
CASE
WHEN P.ABC_CODE = 'D'
   THEN DATEADD(d,CCP.COUNT_FREQ*4,CCP.LAST_COUNT_DATE)  END,

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Annette Wilson, MSISSr. Programmer AnalystAuthor Commented:
Thank you for responding.   I was also thinking the same but I then began to consider that I may need to check to see if the part was previously counted.

Using a multiplier would be correct because I'm only creating a 4 year schedule and do not need to consider whether the part was previously counted within that time frame.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.