Fonction VBScript DatePart
❮ Référence complète de VBScriptLa fonction DatePart renvoie la partie spécifiée d'une date donnée.
Syntaxe
DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
Parameter | Description |
---|---|
interval | Required. The interval of time to return. Can take the following values:
|
date | Required. Date expression to evaluate |
firstdayofweek | Optional. Specifies the day of the week. Can take the following values:
|
firstweekofyear | Optional. Specifies the first week of the year. Can take the following values:
|
Exemples
Exemple 1
Obtenir le mois d'une date :
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
La sortie du code ci-dessus sera :
2
Exemple 2
Obtenez le mois dans lequel nous sommes :
<%
response.write(DatePart("m",Now()))
%>
La sortie du code ci-dessus sera :
1
Exemple 3
Obtenez l'heure :
<%
response.write(DatePart("h",Now())
%>
La sortie du code ci-dessus sera :
13
❮ Référence complète de VBScript