Fonctions VBA : Day, Month et Year

Les fonctions VBA Day, Month et Year renvoient un nombre entier correspondant au jour, au mois ou à l'année de la date spécifiée.

Utilisation :

Day(date)

Month(date)

Year(date)


Exemple d'utilisation

Utilisation des fonctions Day, Month et Year pour récupérer les informations correspondantes d'une date :

Sub exemple()
    
    maDate = #10/30/2024#
    
    MsgBox Day(maDate) 'Renvoie : 30
    MsgBox Month(maDate) 'Renvoie : 10
    MsgBox Year(maDate) 'Renvoie : 2024

End Sub

Ces fonctions acceptent également les dates au format texte :

Sub exemple()
    
    maDate = "30/10/2024"
    
    MsgBox Day(maDate) 'Renvoie : 30
    MsgBox Month(maDate) 'Renvoie : 10
    MsgBox Year(maDate) 'Renvoie : 2024

End Sub