Número de días, meses y años entre 2 fechas

Supongamos que tenemos 2 calendarios y en cada uno de ellos llamaremos las fechas.

'calcula días

Dim fecha1 As Date = Me.Calendar1.SelectedDate '01/10/2012
Dim fecha2 As Date = Me.Calendar2.SelectedDate '07/10/2012
Dim diasa As Integer = DateDiff(DateInterval.Day, fecha1, fecha2)


'calcula meses
Dim fecha1 As Date = Me.Calendar1.SelectedDate '01/10/2012
Dim fecha2 As Date = Me.Calendar2.SelectedDate '07/12/2012
Dim diasa As Integer = DateDiff(DateInterval.Month, fecha1, fecha2)

'calcula años
Dim fecha1 As Date = Me.Calendar1.SelectedDate '01/10/2012
Dim fecha2 As Date = Me.Calendar2.SelectedDate '07/11/2014
Dim diasa As Integer = DateDiff(DateInterval.Year, fecha1, fecha2)

Publicar un comentario

0 Comentarios