I’m looking for an algorithm to find the date of a day in the future, which is in N days from today.
My main problem is how to deal with leap years in the middle.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I take your question correctly, your best option is to do the following:
You can do this using the julian day number for a date.
See the Wikipedia article on Julian Day Number (JDN) for more information.
Having said that, if you’re actually using a modern programming language, most have facilities to deal with dates already, such as Java, C#/.NET, Python, etc.