日期:2014-05-16  浏览次数:21011 次

asp的代码,之前是好的,今天提示“类型不匹配: 'cdate' ”
代码:
if sYear="" or isnull(sYear) then sYear=trim(year(date))
if sMonth="" or isnull(sMonth) then sMonth=trim(month(date)-1)
if sMonth=12 then
CountMonthDay= DateDiff("d", cdate(sYear&"-"&sMonth&"-1"), cdate((sYear+1)&"-1-1"))'计算本月天数
else
CountMonthDay= DateDiff("d", cdate(sYear&"-"&sMonth&"-1"), cdate(sYear&"-"&(sMonth+1)&"-1"))'计算本月天数 //-->提示出错就是这一段代码,不知咋弄!
end if
if cdate(sYear & "-" & sMonth & "-1")>=cdate(year(date) & "-" & month(date) & "-1") then HX_GoBack "统计月份不能大于当前月份!",""
'if not WS_S.HX_Isnum(Did) then Did = cint(LOGdepartment)

------解决方案--------------------
打印下sYear&"-"&sMonth&"-1"的值,看看符合不符合日期格式
------解决方案--------------------
检查数据值
cdate(c1year& "- "&c1month& "- "&c1day) 

------解决方案--------------------
引用:
引用:
检查数据值
cdate(c1year& "- "&c1month& "- "&c1day)


请教检查数据值具体操作方法如何进行!!

response.write
------解决方案--------------------
你的sMonth是0 ,当然会出错啊。

你为什么要month(date)-1呢??


------解决方案--------------------
无语了,不知道你要搞什么

if sMonth="" or isnull(sMonth) then sMonth=trim(month(date)-1)
你这个求月数的为什么要减1??

1-1都等于0了
那么你下面的
cdate(sYear&"-"&sMonth&"-1")这里相当于2011-0-1 能不出错么???
------解决方案--------------------
引用:
之前,系统是在2010年12月31日止都是正常工作的,现在已经2011年1月1日了,系统统计不知该怎么弄!!


上面不是跟你说了吗?月份是0了,有这样的月份吗?
------解决方案--------------------
引用:
引用:
if sYear="" or isnull(sYear) then sYear=trim(year(date))
if sMonth="" or isnull(sMonth) then sMonth=trim(month(date)-1)


if sMonth=12 then
CountMonthDay= DateDiff("d", cda……


自己打印出出来你的

sYear&"-"&sMonth&"-1"
看是什么内容,能转成日期格式吗?

打印出来就知道你在干什么了