如何使用 progress 4gl 计算昨天的记录和今天的记录?

How to calculate yesterday records with today records using progress 4gl?

我写了一个程序,我需要用今天的记录计算昨天的记录(时间 12:00 AM 到 05:00 AM)

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)的订单。你能帮这个案子吗?

据我了解,您需要使用方括号和 "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. 

希望对您有所帮助。

如果您知道您的数据中没有 'future' 日期,您可以使用如下内容:

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.