difference between two dates

Hi,

There is one DB date field DB-DATE (A 8 ) : YYYYMMDD. I need to get the #days i.e. difference between *Current date - DB-DATE. Could you please provide sample code in Natural (Mainframe).

Thanks & Regards
MP

DEFINE DATA LOCAL
1 #DB-DATE (A8) INIT <‘20160214’>
1 #DB-DATEX (D)
1 #DAYS (P6)
END-DEFINE
*
MOVE EDITED #DB-DATE TO #DB-DATEX (EM=YYYYMMDD)
*
COMPUTE #DAYS = *DATX - #DB-DATEX
WRITE 5T ‘DAYS BETWEEN’ #DB-DATE ‘AND TODAY:’ #DAYS
END

Page 1 17-07-26 06:29:05

DAYS BETWEEN 20160214 AND TODAY:     528
DEFINE DATA LOCAL          
1 #DA (A8) INIT<'20170701'>
1 #D  (D)                  
1 #DD (I4)                 
END-DEFINE                 
*                          
#D := VAL(#DA)             
#DD := *DATX - #D          
*                          
WRITE *DATX #D #DD         
*                          
END          

Hi Gurus(both Wolfgang & Steve)

Thank you very much for your immediate response.

Regards
MP