当前位置: 代码迷 >> PB >> 求日期函数,该如何解决
  详细解决方案

求日期函数,该如何解决

热度:50   发布时间:2016-04-29 08:17:51.0
求日期函数
求判断一年的第几周的具体日期范围(周的第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 ldad_f = 1900-01-01; ad_t = ad_fld = date(ai_year, 1, 1) //取该年第一天if (ld = ad_f and ai_year <> 1900) or ai_week < 1 then return //周次小于1,或者年份无效,则返回int li_dnli_dn = DayNumber(ld) //取得该年第一天对应的周别if ab_monday then //以星期一为开始    li_dn --    if li_dn = 0 then li_dn = 7end ifad_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; returnend ifif 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
  相关解决方案