Search code examples
openedgeprogress-4glprogress-db

How to calculate yesterday created records with today?


Hi I would like to know how to calculated records which was created yesterday at some time and calculate with today produced records. please look my code.

   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 and stop_hour = 23:50:00

Here my question is how can calculate records which will be produced by tomorrow with yesterday records. How can i use DATETIME for this?


Solution

  • 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.
    

    Notes:

    1. Function "today" returns a datetype value, dont need casting date();
    2. Use expression "today - 1";
    3. Don't need "if avail" condition for "for each" blocks, if AVM finds any record, it aways avail;