convert time to an integer

chefsride

Member
Can anyone help me with how to convert a character variable holding time (6:30) into an integer so I could add up the time for a certain period of time.
 
This converts it to seconds; if you want minutes, change the 3600 to 60 and do not multiply the minutes with 60.
Code:
DEF VAR cNow     AS CHAR NO-UNDO INIT "6:30":U.  
DEF VAR vSeconds AS INT  NO-UNDO.    
ASSIGN vSeconds = INTEGER(ENTRY(1,cNow,":":U)) * 3600
                + INTEGER(ENTRY(2,cNow,":":U)) * 60.    

MESSAGE vSeconds VIEW-AS ALERT-BOX.
 
Back
Top