Tạo hàm tính năm , ngay , tháng giữa hai thời gian cho trước cần làm như sau :
1. Mở Excel , bâm tổ hợp phím Alt-F11 2. Cửa sổ Microsoft Visual Basic mở ra , chọn menu Insert , chọn Module 3. Bạn cắt dán theo nội dung dưới đây Function Age(Date1 As Date, Date2 As Date) As String
Dim Y As Integer
Dim M As Integer
Dim D As Integer
Dim Temp1 As Date
Temp1 = DateSerial(Year(Date2