时间: 2021-08-13 作者:daque
即日早晨遽然要用到一个计划半月有几何天的因变量,翻了半天没找到体例自带着中因变量,所以发端写了一个,如次: **归来某个月有几何天 function howmonthday() parameters cdate local days as integer ,years as integer if !type("cdate")=="d" messagebox("参数典型不精确,该当为日子型","体例提醒!") return endif days=iif(inlist(month(cdate),1,3,5,7,8,10,12),31,30) **闰年计划本领 years=year(cdate) if month(cdate)==2 days = iif(years%400==0 or (years%4==0 and years%100<>0),29,28) endif return days endfunc 厥后郑宇年老给我供给了一个归来月尾的因变量。如次: procedure edom * function: 归来本月月尾 * m.l.y 1998.8.8 parameters date_today private all set date to ansi set century on if month(date_today) < 12 return ctod(str(year(date_today),4,0) + "." ; + str(month(date_today)+1,2,0) + ".01") - 1 else return edoy(date_today) endif 推敲了半天创造归来月尾大概还要简简单点,我矫正了一下: cdate=date() ??cdate+(32-day(cdate))-day(cdate+(32-day(cdate))) 结果用这个思绪矫正了一下归来半月有几何天的因变量,如次: function howmonthday() parameters cdate local days as integer if !type("cdate")=="d" messagebox("参数典型不精确,该当为日子型","体例提醒!") return endif days=day(cdate+(32-day(cdate))-day(cdate+(32-day(cdate)))) return days endfunc 本来最要害的惟有一句:days=day(cdate+(32-day(cdate))-day(cdate+(32-day(cdate)))) 也不必管闰年常年了,方便。 假如归来月尾,那这句改为:cdate+(32-day(cdate))-day(cdate+(32-day(cdate))) 即可 道理即是按照减少值来计划当月的下一个月胜过几天,而后减去几天即是当月的结果一天了。