Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Expert,

I have the following which does month arithmetic as follows in ms sql server stored procedure.
SQL
@CCMTH is the current month
@CCYR is the current year all in an incremental loop

IF @CCMTH = 12
BEGIN	
SET @CCMTH = 1	
SET @CCYR = @CCYR+1
END
ELSE
IF @CCMTH <> 12	
BEGIN
SET @CCMTH =@CCMTH+1	
SET @CCYR =@CCYR
END

Need to apply the same concept now on quarterly basics i.e the increment will now be 3 instead of 1.

Please provide the codes to cater for this.
The challenge is how to handle when the increment in month goes beyond 12

Thanks
Posted
Updated 1-Mar-15 1:02am
v3
Comments
Maciej Los 1-Mar-15 5:40am    
Not a question at all!
Sergey Alexandrovich Kryukov 1-Mar-15 7:01am    
The expression "quarterly arithmetic" or "monthly arithmetic" makes approximately as much sense as expressions "globe of USA" or "globe of New York". Or "pencil for writing in English".
—SA
Richard MacCutchan 1-Mar-15 7:58am    
This is just a question of adding 3 to the month and testing for values greater than 12. Not exactly a complicated algorithm for even an average developer.
Maciej Los 1-Mar-15 9:28am    
My virtual 5!
Member 10744248 2-Mar-15 11:05am    
Its more than you think.

please

1 solution

"Please provide the codes to cater for this."


It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys.

Alternatively, show us what you have tried, and we might help you fix it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900