Fungsi Bagian Tanggal VBScript
Referensi VBScript LengkapFungsi DatePart mengembalikan bagian tertentu dari tanggal tertentu.
Sintaksis
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:
|
Contoh
Contoh 1
Dapatkan bulan dari tanggal:
<%
d=CDate("2010-02-16")
response.write(DatePart("m",d))
%>
Output dari kode di atas akan menjadi:
2
Contoh 2
Dapatkan bulan kami berada:
<%
response.write(DatePart("m",Now()))
%>
Output dari kode di atas akan menjadi:
1
Contoh 3
Dapatkan jamnya:
<%
response.write(DatePart("h",Now())
%>
Output dari kode di atas akan menjadi:
13
Referensi VBScript Lengkap