Subtracting dates to get time in years

  • Follow


Hey guys,

I'm trying to determine a time interval (in years) between 2 date vectors. I'm working with coupon bonds so I need to know how much time between today's date and the expiry of the bond.

Assume today is March 31, 1997: the date number is = 729480
Let's the say the bond expires on: October 15, 2026, date number = 740270.

Is there a way to manipulate these two date numbers so I can get the difference between them in years? (around 29.xx years)

Thanks,
Anthony
0
Reply Anthony 10/9/2010 5:02:03 PM

"Anthony " <antfarinaccio@gmail.comremove.spam> wrote in message <i8q76b$fh7$1@fred.mathworks.com>...
> Hey guys,
> 
> I'm trying to determine a time interval (in years) between 2 date vectors. I'm working with coupon bonds so I need to know how much time between today's date and the expiry of the bond.
> 
> Assume today is March 31, 1997: the date number is = 729480
> Let's the say the bond expires on: October 15, 2026, date number = 740270.
> 
> Is there a way to manipulate these two date numbers so I can get the difference between them in years? (around 29.xx years)
> 
> Thanks,
> Anthony

For an approximate answer:

(datenum2 - datenum1)/365.25

James Tursa
0
Reply James 10/9/2010 7:40:05 PM


Thanks James!
That works for me!


Anthony
0
Reply Anthony 10/9/2010 7:52:03 PM

2 Replies
803 Views

(page loaded in 0.013 seconds)

Similiar Articles:













7/24/2012 7:21:06 AM


Reply: