VBScriptDatePart関数_
❮完全な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リファレンス