Hàm DatePart của VBScript
❮ Tham khảo VBScript hoàn chỉnhHàm DatePart trả về phần đã chỉ định của một ngày nhất định.
Cú pháp
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:
|
Ví dụ
ví dụ 1
Lấy tháng kể từ một ngày:
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
Đầu ra của đoạn mã trên sẽ là:
2
Hiển thị ví dụ »Ví dụ 2
Nhận tháng chúng tôi đang ở:
<%
response.write(DatePart("m",Now()))
%>
Đầu ra của đoạn mã trên sẽ là:
5
Hiển thị ví dụ »Ví dụ 3
Lấy giờ:
<%
response.write(DatePart("h",Now())
%>
Đầu ra của đoạn mã trên sẽ là:
16
Hiển thị ví dụ »❮ Tham khảo VBScript hoàn chỉnh