壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1899|回复: 4

在写SQR时遇到的一个问题

[复制链接]
发表于 2008/1/25 16:41:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
<DIV>已知Begin_Dt和End_Dt,怎样去计算这段时间Cover了几次12:00和18:00呢?</DIV>
<DIV>Example: </DIV>
<DIV>1)Begin_Dt='2007-10-25 18:01';&nbsp;&nbsp; End_Dt=''2007-10-25 20:30'&nbsp; </DIV>
<DIV>&nbsp; 则Cover_Number=0</DIV>
<DIV>2)Begin_Dt='2007-10-29 18:00';&nbsp;&nbsp; End_Dt=''2007-10-29 20:30'&nbsp; </DIV>
<DIV>&nbsp; 则Cover_Number=1</DIV>
<DIV>3)Begin_Dt='2007-11-03 11:00';&nbsp;&nbsp; End_Dt=''2007-11-04 19:20'&nbsp; </DIV>
<DIV>&nbsp; 则Cover_Number=4</DIV>
 楼主| 发表于 2008/1/25 16:45:55 | 显示全部楼层
借鉴别人的,但还是不能太明白道理(#HourDiff=(#BeginHrs-#EndHrs)化为小时数)

Cover_12and18_By_DateTime(#BeginHrs,#EndHrs,#HourDiff,:#Count)
let #Count=0
if #BeginHrs&lt;=12 and #BeginHrs+#HourDiff&gt;=12
   add 1 to #Count
end-if
if #BeginHrs&lt;=18 and #BeginHrs+#HourDiff&gt;=18
   add 1 to #Count
end-if
let #TempHrs=(#HourDiff+#BeginHrs-12)/24
let #i=0
while #i&lt;=#TempHrs
  if #TempHrs&gt;=1
    add 1 to #Count
  end-if
  add 1 to #i
  let #TempHrs = #TempHrs-1
end-while
let #TempHrs= (#HourDiff+#BeginHrs-18)/24
let #j=0
while #j&lt;=#TempHrs
  if #TempHrs&gt;=1
    add 1 to #Count
  end-if
  add 1 to #j
  let #TempHrs=#TempHrs-1
end-while
Cover_12and18_By_DateTime

注:#BeginHrs,#EndHrs分是Begin_Dt和End_Dt的开始时数。
如:Begin_Dt='2007-10-25 18:01';   End_Dt=''2007-10-25 20:30'  
则:#BeginHrs=18;#EndHrs=20.5
发表于 2009/2/21 17:52:02 | 显示全部楼层
是ppsoft 的语法,我没写过,看不懂。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 06:49 , Processed in 0.011866 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表