# Date math makes me crazy

**URL:** <https://www.ruby-forum.com/t/date-math-makes-me-crazy/130163>\
**Category:** Rails\
**Created:** [February 25, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/date-math-makes-me-crazy/130163 "2008-02-25T23:52:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 25, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/date-math-makes-me-crazy/130163/1 "2008-02-25T23:52:55Z")

</div>

I just don’t understand this and leap years make this problem obvious to  
me…

> > test = DateTime.now  
> > =\> #\<DateTime: 53017684949923739/21600000000,-7/24,2299161\>
> 
> > test.strftime("%Y-%m-%d")  
> > =\> “2008-02-25”

> > test = DateTime.now + 365  
> > =\> #\<DateTime: 70700758603797619/28800000000,-7/24,2299161\>
> 
> > test.strftime("%Y-%m-%d")  
> > =\> “2009-02-24”

seems reasonable, off a day because of leap year…

> > test = DateTime.now + 1.year  
> > =\> #\<DateTime: 1469323689922559749/43200000000,-7/24,2299161\>
> 
> > test.strftime("%Y-%m-%d")  
> > =\> “88409-12-04”

how do I add a simple year?

Craig
