查看DateDiff函数:
http://www.w3schools.com/vbscript/func_datediff.asp
。示例:
diff = DateDiff("d", "02/19/2015", "02/20/2015") ' difference in days
diff = DateDiff("h", "02/19/2015", "02/20/2015") ' difference in hours
diff = DateDiff("n", "02/19/2015", "02/20/2015") ' difference in mins
diff = DateDiff("s", "02/19/2015", "02/20/2015") ' difference in seconds
要计算差值,需要从字符串中解析出日期并使用DateDiff。
日期的顺序决定了输出。在上面的示例中,所有值都将为正值。如果还原它们,输出结果将为负值。提供相同的日期/时间将导致0。
diff = DateDiff("d", "02/20/2015", "02/19/2015") ' output = -1
diff = DateDiff("d", "02/20/2015", "02/20/2015") ' output = 0