求日期函数,该如何解决
求日期函数
求判断一年的第几周的具体日期范围(周的第1天是星期天):
比如: 2012年第1周 日期范围是 2012.1.1~2012.1.7
2012年第2周 日期范围是 2012.1.8~2012.1.14
最好是周的第一天是星期1的函数
------解决方案--------------------
http://user.qzone.qq.com/605932316/infocenter#!app=2&pos=1322717001
看看这里的23符合你要求不?
------解决方案--------------------
求判断一年的第几周的具体日期范围(周的第1天是星期天):
比如: 2012年第1周 日期范围是 2012.1.1~2012.1.7
2012年第2周 日期范围是 2012.1.8~2012.1.14
最好是周的第一天是星期1的函数
------解决方案--------------------
http://user.qzone.qq.com/605932316/infocenter#!app=2&pos=1322717001
看看这里的23符合你要求不?
------解决方案--------------------
- C/C++ code
global subroutine f_year_week (integer ai_year, integer ai_week, boolean ab_monday, ref date ad_f, ref date ad_t);//================================================== //获取某年第几周的开始日期和结束日期 //================================================== // 参数 // value integer ai_year 年份 // value integer ai_week 第几周 // value boolean ab_monday 周开始日期是否为星期一 // reference date ad_f 周的第一天 // reference date ad_t 周的最后一天 //================================================== date ld ad_f = 1900-01-01; ad_t = ad_f ld = date(ai_year, 1, 1) //取该年第一天 if (ld = ad_f and ai_year <> 1900) or ai_week < 1 then return //周次小于1,或者年份无效,则返回 int li_dn li_dn = DayNumber(ld) //取得该年第一天对应的周别 if ab_monday then //以星期一为开始 li_dn -- if li_dn = 0 then li_dn = 7 end if ad_f = RelativeDate ( ld, (ai_week - 1) * 7 - li_dn + 1) //取得周的开始 ad_t = RelativeDate( ad_f, 6) //取得周的结尾 if year(ad_f) <> ai_year and year(ad_t) <> ai_year then //周次太大了,已经不是ai_year年了,返回 ad_f = 1900-01-01; ad_t = ad_f; return end if if year(ad_f) <> ai_year then ad_f = ld //当开始日期为ai_week的上一年时,开始日期强制为1月1日 if year(ad_t) <> ai_year then ad_t = date(ai_year, 12, 31) //当结束日期为ai_week的下一年时,强制为最后一天 end subroutine