asp中,如何计算时间天数的差??

来源:百度知道 编辑:UC知道 时间:2024/05/16 04:03:38
请大家注意,我想计算“某月25日”和“某月的下一个月的10号”相差多少天!!
某月,取系统时间的月份...

代码应该怎么写啊?
看不懂1楼在写什么....
注意一下哈,月份是不固定的,是系统时间的月份
2楼的不错,如果能把response.write getDays(2007,3)里面的3改成系统的月份是不是替换为Month(Now())啊?
如果日期要调用数据库中字段payback里面的数据的话,
strDate1=strYear & "-" & strMonth & "-10"
strDate2=intYear & "-" & intMonth & "-25" 应该怎么改动??

response.write getDays()
function getDays()
dim intYear,intMonth
dim strYear,strMonth,strDate1,strDate2
intYear=year(date)
intMonth=month(date)
if intMonth=12 then
strYear=intYear+1
strMonth="1"
else
strYear=cstr(intYear)
strMonth=cstr(intMonth+1)
end if
strDate1=strYear & "-" & strMonth & "-10"
strDate2=intYear & "-" & intMonth & "-25"

getDays=datediff("d",cdate(strDate2),cdate(strDate1))
end function

这样:

Response.write CDate(now) - CData("2007-10-01")