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/2023#
MsgBox Day(maDate) 'Renvoie : 30
MsgBox Month(maDate) 'Renvoie : 10
MsgBox Year(maDate) 'Renvoie : 2023
End Sub
Ces fonctions acceptent également les dates au format texte :
Sub exemple()
maDate = "30/10/2023"
MsgBox Day(maDate) 'Renvoie : 30
MsgBox Month(maDate) 'Renvoie : 10
MsgBox Year(maDate) 'Renvoie : 2023
End Sub