嗨,我想知道如何计算昨天在某个时间创建的记录,并用今天生成的记录计算。请查看我的代码。
FOR EACH womf_worder OF sfcf_au_ship WHERE womf_worder.word_production_status = "B"
AND womf_worder.word_build_date = DATE(TODAY)
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:
IF AVAILABLE womf_worder THEN DO:
i = i + 1.
END.
tt_shift.shft_start_hour = 06:00:00和stop_hour = 23:50:00
在这里,我的问题是如何计算明天将用昨天记录产生的记录。我如何使用DATETIME?
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.
笔记:
如果数据库中的任何字段是DATETIME,则DATETIME将非常有用。快速锁定您的示例让我觉得您有单独的日期和时间字段。我不确定TIME字段是什么。也许是整数或字符串?
您不需要在FOR循环中进行可用性检查。这是FINDS和可能的JOINS,其中一个记录可能在循环中不可用。对于基本的FOR EACH,只会处理可用的记录。
如果时间确实是整数或字符串,那么您的代码可以很好地处理可用性检查的小修复。
FOR EACH womf_worder OF sfcf_au_ship WHERE womf_worder.word_production_status = "B"
AND womf_worder.word_build_date = DATE(TODAY)
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:
i = i + 1.
END.