Add and subtract six months using the >> and << methods. : Date Calculation « Date « Ruby






Add and subtract six months using the >> and << methods.


require 'date'

date = Date.new( 2006, 11, 8 )

puts (date >> 6).to_s 
puts (date << 6).to_s 

 








Related examples in the same category

1.Subtract 61 days from a date:
2.Doing Date Arithmetic
3.Doing DateTime Arithmetic
4.Minus one DateTime from another
5.Move DateTime
6.leap year day
7.Counting the Days Since an Arbitrary Date
8.advent calendar
9.Minus DateTime by day
10.Remaining days