【问题标题】:How to calculate yesterday records with today records using progress 4gl?如何使用progress 4gl计算昨天的记录和今天的记录?
【发布时间】:2019-06-03 21:40:43
【问题描述】:

我已经写了一个程序,我需要用今天的记录来计算昨天的记录(从 12:00 到 05:00)

for each womf_worder of sfcf_au_ship where 
         womf_worder.word_production_status EQ "B"                      and 
         womf_worder.word_build_date        EQ today - 1                and 
         womf_worder.word_build_time        GE tt_shift.shft_start_hour and
         womf_worder.word_build_time        LE tt_shift.shft_stop_hour  
         no-lock: 

    assign i = i + 1.
end.

但问题是我只需要根据今天的记录计算那些提到的时间(12:00 AM 到 05:00 AM)的订单。你能帮帮我吗?

【问题讨论】:

  • 对不起,我不太明白你想做什么。您的代码示例在某个时间间隔内计算昨天创建的记录(?)。 “用今天的记录计算……”到底是什么意思?
  • 是的,我想将昨天的记录与今天的记录一起计算,即仅将昨天的记录与今天的记录一起计算到凌晨 05:00
  • 如果您提供输入数据样本和预期输出可能会有所帮助
  • 我同意 Stefan 的观点,这可能更容易理解你的意思。

标签: openedge progress-4gl


【解决方案1】:

如果您知道您的数据中没有“未来”日期,则可以使用以下内容:

for each womf_worder of sfcf_au_ship where 
         womf_worder.word_production_status EQ "B"                      and 
         womf_worder.word_build_date        GE today - 1                and 
         womf_worder.word_build_time        GE tt_shift.shft_start_hour and
         womf_worder.word_build_time        LE tt_shift.shft_stop_hour  
         no-lock: 

  assign i = i + 1.
end.

如果您不熟悉您正在使用的数据或希望它更便携:

for each womf_worder of sfcf_au_ship where 
         womf_worder.word_production_status EQ "B"                      and 
         womf_worder.word_build_time        GE tt_shift.shft_start_hour and
         womf_worder.word_build_time        LE tt_shift.shft_stop_hour  and
         ( womf_worder.word_build_date      eq today - 1                or
           womf_worder.word_build_date      eq today                       )
         no-lock: 

  assign i = i + 1.
end.

【讨论】:

    【解决方案2】:

    据我了解,您需要使用括号和“OR”运算符, 所以你需要这样的东西:

    FOR EACH  womf_worder OF sfcf_au_ship no-lock
       WHERE  womf_worder.word_production_status EQ "B"                      
         AND (womf_worder.word_build_date        EQ today - 1                
         AND  womf_worder.word_build_time        GE tt_shift.shft_start_hour)
          OR (womf_worder.word_build_date        EQ today 
         AND  womf_worder.word_build_time        LE tt_shift.shft_stop_hour)
              : 
       ASSIGN i = i + 1.
    END. 
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 2014-12-07
      • 1970-01-01
      • 2020-05-18
      • 2010-12-07
      • 1970-01-01
      相关资源
      最近更新 更多