ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Difference between two timestamp fields in Cobol/400

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between two timestamp fields in Cobol/400

    Hi All,

    i have a simple doubt about Cobol/400, since i didnt found any Forum for Cobol i m placing my doubt here

    I m having 2 timestamp fields of format (YYDDDHHMMSSMM).
    & i want to check whether the difference between them is 60 sec. or more.
    If it is more than 60 sec then i need to call a module.

    So pls tell me how can i get the difference between two timestamp fields in Cobol/400.

    Thanks,
    Prashant..

  • #2
    Re: Difference between two timestamp fields in Cobol/400

    Hi,

    I am new to COBOL/400 programming.

    I tried this with a sample program.

    The logic behind the the value in Field2 should be Greater than or Equal to Field1.

    For to be greater than 60 seconds, the fields should differ by atleast a minute.

    PHP Code:
    IDENTIFICATION DIVISION.                              
    PROGRAM-IDTESTCOBOL.                                
                                                          
    ENVIRONMENT DIVISION.                                 
    CONFIGURATION SECTION.                                
    SOURCE-COMPUTERAS400.                               
    OBJECT-COMPUTERAS400.                               
                                                          
    DATA DIVISION.                                        
    WORKING-STORAGE SECTION.                              
    01  WS-DATETIME1-FIELD.                               
        
    05 WK-TIME1.                                      
           
    10 WK-TIME1-YY         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME1-DDD        PIC 9(003VALUE ZERO.  
           
    10 WK-TIME1-HH         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME1-MM         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME1-SS         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME1-MS         PIC 9(002VALUE ZERO.  
    01  WS-DATETIME2-FIELD.                               
        
    05 WK-TIME2.                                      
           
    10 WK-TIME2-YY         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME2-DDD        PIC 9(003VALUE ZERO.  
           
    10 WK-TIME2-HH         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME2-MM         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME2-SS         PIC 9(002VALUE ZERO.  
           
    10 WK-TIME2-MS         PIC 9(002VALUE ZERO.  
                                                          
    PROCEDURE DIVISION.                                   
        
    PARAGRAPH-TEST.                                   
                                                          
        
    ACCEPT WS-DATETIME1-FIELD.                        
        
    ACCEPT WS-DATETIME2-FIELD.                        
                                                          
        IF     (
    WK-TIME2-YY  WK-TIME1-YY)               
            OR (
    WK-TIME2-DDD WK-TIME1-DDD)              
            OR (
    WK-TIME2-HH  WK-TIME1-HH)               
            OR (
    WK-TIME2-MM  WK-TIME1-MMTHEN          
                 DISPLAY 
    'CALLMOD'                        
        
    END-IF.                                           
        
    END PROGRAM TESTCOBOL

    Comment


    • #3
      Re: Difference between two timestamp fields in Cobol/400

      Hi Surya,
      thanks for ur suggestion
      For that u have to chk first whether the date is same or not ?
      If it is same then do the conversions & compare the time
      But if the date is not same then we have to check the condition where the date difference is 1.
      eg. at date 08/02/2007 & tiime 23:59:09 & the second field having date 09/02/2007 & time 00:00:02.
      In this case the time diff is less than 1 min .

      Prashant.

      Comment


      • #4
        Re: Difference between two timestamp fields in Cobol/400

        Prasanth,

        I do agree with u

        Comment

        Working...
        X