บทช่วยสอน ASP

ASP HOME

กวดวิชา WP

แนะนำหน้าเว็บ มีดโกนหน้าเว็บ เค้าโครงหน้าเว็บ โฟลเดอร์หน้าเว็บ หน้าเว็บทั่วโลก แบบฟอร์มหน้าเว็บ วัตถุหน้าเว็บ ไฟล์หน้าเว็บ ฐานข้อมูลหน้าเว็บ ผู้ช่วยหน้าเว็บ หน้าเว็บ WebGrid แผนภูมิหน้าเว็บ อีเมลหน้าเว็บ ความปลอดภัยของหน้าเว็บ เผยแพร่หน้าเว็บ ตัวอย่างหน้าเว็บ ชั้นเรียนของหน้าเว็บ

มีดโกน ASP.NET

แนะนำมีดโกน มีดโกนไวยากรณ์ มีดโกน C# ตัวแปร มีดโกน C# ลูป มีดโกน C# Logic ตัวแปรมีดโกน VB มีดโกน VB Loops มีดโกน VB Logic

ASP Classic

แนะนำ ASP ไวยากรณ์ ASP ตัวแปร ASP ขั้นตอน ASP เงื่อนไข ASP ASP วนรอบ แบบฟอร์ม ASP คุกกี้ ASP เซสชัน ASP แอปพลิเคชัน ASP ASP #รวม ASP Global.asa ASP AJAX อีเมล ASP ตัวอย่าง ASP

การอ้างอิง ASP

ฟังก์ชัน ASP VB คีย์เวิร์ด ASP VB การตอบสนอง ASP คำขอ ASP แอปพลิเคชัน ASP เซสชัน ASP เซิร์ฟเวอร์ ASP ข้อผิดพลาด ASP ASP FileSystem ASP TextStream ไดรฟ์ ASP ไฟล์ ASP โฟลเดอร์ ASP พจนานุกรม ASP ASP AdRotator ASP BrowserCap การเชื่อมโยงเนื้อหา ASP ตัวหมุนเนื้อหา ASP ASP Quick Ref

กวดวิชา ADO

แนะนำ ADO ADO Connect ชุดระเบียน ADO จอแสดงผล ADO แบบสอบถาม ADO ADO Sort เพิ่ม ADO ADO Update ADO ลบ สาธิต ADO ADO เร่งความเร็ว

วัตถุ ADO

คำสั่ง ADO การเชื่อมต่อ ADO ข้อผิดพลาด ADO ADO Field พารามิเตอร์ ADO ADO พร็อพเพอร์ตี้ บันทึก ADO ชุดระเบียน ADO ADO สตรีม ประเภทข้อมูล ADO

ฟังก์ชันVBScript DateDiff

❮ การอ้างอิง VBScript ที่สมบูรณ์

ฟังก์ชัน DateDiff ส่งกลับจำนวนช่วงระหว่างวันที่สองวัน

ไวยากรณ์

DateDiff(interval,date1,date2[,firstdayofweek[,firstweekofyear]])
Parameter Description
interval Required. The interval you want to use to calculate the differences between date1 and date2

Can take the following values:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second
date1,date2 Required. Date expressions. Two dates you want to use in the calculation
firstdayofweek Optional. Specifies the day of the week.

Can take the following values:

  • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
  • 1 = vbSunday - Sunday (default)
  • 2 = vbMonday - Monday
  • 3 = vbTuesday - Tuesday
  • 4 = vbWednesday - Wednesday
  • 5 = vbThursday - Thursday
  • 6 = vbFriday - Friday
  • 7 = vbSaturday - Saturday
firstweekofyear Optional. Specifies the first week of the year.

Can take the following values:

  • 0 = vbUseSystem - Use National Language Support (NLS) API setting
  • 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default)
  • 2 = vbFirstFourDays - Start with the week that has at least four days in the new year
  • 3 = vbFirstFullWeek - Start with the first full week of the new year

ตัวอย่าง

ตัวอย่าง 1

ความแตกต่างระหว่าง 31 มกราคม 2009 และ 31 มกราคม 2010:

<%

fromDate="31-Jan-09 00:00:00"
toDate="31-Jan-10 23:59:00"
response.write(DateDiff("yyyy",fromDate,toDate) & "<br />")
response.write(DateDiff("q",fromDate,toDate) & "<br />")
response.write(DateDiff("m",fromDate,toDate) & "<br />")
response.write(DateDiff("y",fromDate,toDate) & "<br />")
response.write(DateDiff("d",fromDate,toDate) & "<br />")
response.write(DateDiff("w",fromDate,toDate) & "<br />")
response.write(DateDiff("ww",fromDate,toDate) & "<br />")
response.write(DateDiff("h",fromDate,toDate) & "<br />")
response.write(DateDiff("n",fromDate,toDate) & "<br />")
response.write(DateDiff("s",fromDate,toDate) & "<br />")

%>

ผลลัพธ์ของโค้ดด้านบนจะเป็น:

1
4
12
365
365
52
53
8783
527039
31622340

ตัวอย่าง 2

กี่สัปดาห์ (เริ่มในวันจันทร์)
ระหว่างวันที่ 31 ธันวาคม 2552 ถึง 31 ธันวาคม 2555:

<%

fromDate=CDate("2009/12/31")
toDate=CDate("2012/12/31")
response.write(DateDiff("w",fromDate,toDate,vbMonday))

%>

ผลลัพธ์ของโค้ดด้านบนจะเป็น:

156

❮ การอ้างอิง VBScript ที่สมบูรณ์