   1. Function TrouveSemaineDeLaDate(ByVal DateConcernee As Date) As String
   2.    ' Bogue du lundi 29 décembre 2003 qui est compté en semaine 53 au lieu de semaine 1
   3.    If Format(DateConcernee, "dd/mm/yyyy", vbMonday, vbFirstFourDays) = "29/12/2003" Then
   4.       TrouveSemaineDeLaDate = "01"
   5.    Else
   6.       TrouveSemaineDeLaDate = Format(Format(DateConcernee, "ww", vbMonday, vbFirstFourDays), "00")
   7.    End If
   8. End Function
   9.  
  10.  
  11. Function TrouveAnneeDeLaDate(ByVal DateConcernee As Date) As String
  12.    ' Bogue du lundi 29 décembre 2003 qui est compté en semaine 53 au lieu de semaine 1
  13.    If Format(DateConcernee, "dd/mm/yyyy", vbMonday, vbFirstFourDays) = "29/12/2003" Then
  14.       TrouveAnneeDeLaDate = "2004"
  15.    Else
  16.       TrouveAnneeDeLaDate = Format(DateConcernee, "yyyy", vbMonday, vbFirstFourDays)
  17.    End If
  18. End Function


' temps écoulé entre deux date
Dim date1 As Date, date2 As Date

date1 = "01/01/2004"
date2 = "01/01/2005"

MsgBox "Durée en jours : " & DateDiff("d", date1, date2)
MsgBox "Durée en nombre de mois : " & DateDiff("m", date1, date2)

' ajouter des heures, des jours ou des mois à une date
today = Now()

DateAdd("m", 3, today)   'renvoie today + 3 mois
DateAdd("d", 2, today)   'renvoie today + 2 jours
DateAdd("ww", 1, today)  'renvoie today + 1 semaine
DateAdd("h", 1, today)   'renvoie today + 1 heure


' obtenir une date à partir des numéros du jours, de la semaine et de l'année
Public Function InvDatePart(ByVal PosJour As Integer, ByVal NumSemaine As Integer, ByVal Annee As Integer) As Date
   
    Dim tmpDate As Date

    tmpDate = CDate("1/1/" & Format$(Annee))
    If Weekday(tmpDate, vbMonday) < 6 Then NumSemaine = NumSemaine - 1
    tmpDate = DateAdd("ww", NumSemaine, tmpDate)
    tmpDate = DateAdd("d", PosJour - Weekday(tmpDate, vbMonday), tmpDate)
    InvDatePart = tmpDate

End Function


     A1:            B1: START        C1: DAYS          D1: DAYS
     A2: TASK       B2: DATE         C2: COMPLETED     D2: REMAINING
     A3: TASK-1     B3: 1/1/91       C3: 150           D3: 15
     A4: TASK-2     B4: 5/1/91       C4: 21            D4: 31
     A5: TASK-3     B5: 7/1/91       C5: 0             D5: 114
     A6: TASK-4     B6: 10/1/91      C6: 0             D6: 4
     A7: TASK-5     B7: 10/15/91     C7: 0             D7: 31
     A8: TASK-6     B8: 11/1/91      C8: 0             D8: 2
     
     
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), Month(Date1), Day(Date1))
    Y = Year(Date2) - Year(Date1) + (Temp1 > Date2)          
    M = Month(Date2) - Month(Date1) - (12 * (Temp1 > Date2)) 
    D = Day(Date2) - Day(Date1)                              
    If D < 0 Then                                            
        M = M - 1                                            
        D = Day(DateSerial(Year(date2), Month(date2), 0)) + D
    End If                                                   
    Age = Y & " years " & M & " months " & D & " days"       
End Function                                                 
                                                             