Funkcja VBScript DatePart
❮ Pełne odniesienie do VBScriptFunkcja DatePart zwraca określoną część podanej daty.
Składnia
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:
|
Przykłady
Przykład 1
Pobierz miesiąc od daty:
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
Wynikiem powyższego kodu będzie:
2
Przykład 2
Pobierz miesiąc, w którym jesteśmy:
<%
response.write(DatePart("m",Now()))
%>
Wynikiem powyższego kodu będzie:
1
Przykład 3
Pobierz godzinę:
<%
response.write(DatePart("h",Now())
%>
Wynikiem powyższego kodu będzie:
13
❮ Pełne odniesienie do VBScript