Adding dates
-
How can I add 12 years minus 1 day to a date please? So, for example, if the original date is 09/06/2009 (June 9th, 2009) the calculated date will give me 08/06/2021.
-
How can I add 12 years minus 1 day to a date please? So, for example, if the original date is 09/06/2009 (June 9th, 2009) the calculated date will give me 08/06/2021.
Did you take a look at MSDN? The DateTime class contains methods for this: http://msdn.microsoft.com/en-us/library/system.datetime.addyears(VS.80).aspx[^] Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
How can I add 12 years minus 1 day to a date please? So, for example, if the original date is 09/06/2009 (June 9th, 2009) the calculated date will give me 08/06/2021.
Something like this perhaps:
DateTime newDate = DateTime.Now.AddYears(12).AddDays(-1);
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
How can I add 12 years minus 1 day to a date please? So, for example, if the original date is 09/06/2009 (June 9th, 2009) the calculated date will give me 08/06/2021.
public DateTime TwelveYearsMinusOne(DateTime start)
{
return start.AddYears(12).AddDays(-1);
}Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
Did you take a look at MSDN? The DateTime class contains methods for this: http://msdn.microsoft.com/en-us/library/system.datetime.addyears(VS.80).aspx[^] Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
I have just realised this after I posted my question :rolleyes: Many thanks for pointing this out.