Click here to Skip to main content
15,905,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all, i have a problem in Mysql Query..

I have data:
- 21 April 1989
- 20 May 2010
- 11 January 2001

The Result i need is a multiple of 2 year that will happen next (Today:2 Jan 2012):
- 21 April 2013
- 20 May 2012
- 11 January 2013

How can i have it? I already tried many ways and did not work..

Sorry for my bad English..
Posted
Comments
Prasad_Kulkarni 2-Jan-12 6:00am    
can u please give some more explanation..and don't feel for your language..this site having many experts who edits your question..just elaborate it,so everyone can at least understand what you wanna say..
Dwi Prawira 2-Jan-12 6:06am    
actually it is just odd-even year..
if i have 21 April 1989 which is an odd year, i should have 21 April 2013.
20 May 2010 is even, so i should have 20 May 2012. If this is 01-Jan-2014, than it must return 21 April 2015 and 20 May 2014..

Thanks for advance..

1 solution

You may use the MOD operator, for instance, try:
SQL
select MAKEDATE(2012 + MOD(YEAR("1989-04-21"),2), DAYOFYEAR("1989-04-21"));
 
Share this answer
 
v2
Comments
Dwi Prawira 2-Jan-12 6:16am    
How about if the i gave the result an
WHERE RESULT BETWEEN '02-May-2012' AND '02-May-2013'?

The Result should be NULL since it not posible..

Thanks for your solution. :)

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