Funzione VBScript DatePart
❮ Riferimento completo di VBScriptLa funzione DatePart restituisce la parte specificata di una data data.
Sintassi
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:
|
Esempi
Esempio 1
Ottieni il mese da una data:
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
L'output del codice sopra sarà:
2
Esempio 2
Ottieni il mese in cui siamo:
<%
response.write(DatePart("m",Now()))
%>
L'output del codice sopra sarà:
1
Esempio 3
Ottieni l'ora:
<%
response.write(DatePart("h",Now())
%>
L'output del codice sopra sarà:
13
❮ Riferimento completo di VBScript