وظيفة DatePart في VBScript
التعريف والاستخدام
يمكن للوظيفة DatePart العودة إلى جزء معين من تاريخ معين.
ملاحظة:يؤثر معامل firstdayofweek على الحسابات التي تستخدم علامات الفارق الزمني "w" و "ww".
النحو
DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
المتغيرات | وصف |
---|---|
interval |
مطلوب. وحدة الوقت لقياس الفارق بين date1 و date2. يمكن استخدام القيم التالية:
|
date | مطلوب. تعبير تاريخي يجب حسابه. |
firstdayofweek |
اختياري. يحدد عدد أيام الأسبوع، أي اليوم الذي يقع فيه الأسبوع. يمكن استخدام القيم التالية:
|
firstweekofyear |
اختياري. يحدد الأسبوع الأول من السنة. يمكن استخدام القيم التالية:
|
Instance
Example 1
d = #2/10/96 16:45:30# document.write(DatePart("yyyy",d)) 'Output: 1996' document.write(DatePart("m",d)) 'Output: 2' document.write(DatePart("d",d)) 'Output: 10' document.write(DatePart("h",d)) 'Output: 16' document.write(DatePart("n",d)) 'Output: 45' document.write(DatePart("s",d)) 'Output: 30' document.write(DatePart("q",d)) 'Output: 1, February is the 1st quarter.' document.write(DatePart("y",d)) 'Output: 41, February 10 is the 41st day of 1996.' document.write(DatePart("ww",d)) 'Output: 6, February 10 is the 6th week of 1996.' document.write(DatePart("w",d)) 'Output: 7, February 10, 1996 is the 6th week's 7th day (Saturday).'