COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### 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

```"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

(datenum2 - datenum1)/365.25

James Tursa
```
 0

```Thanks James!
That works for me!

Anthony
```
 0

2 Replies
803 Views

Similiar Articles:

7/24/2012 7:21:06 AM