Функция VBScript DatePart
❮ Полный справочник VBScriptФункция DatePart возвращает указанную часть заданной даты.
Синтаксис
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:
|
Примеры
Пример 1
Получить месяц из даты:
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
Вывод кода выше будет:
2
Пример 2
Получить месяц, в котором мы находимся:
<%
response.write(DatePart("m",Now()))
%>
Вывод кода выше будет:
1
Пример 3
Получить час:
<%
response.write(DatePart("h",Now())
%>
Вывод кода выше будет:
13
❮ Полный справочник VBScript