In your original program, this statement is incorrect and should be removed:
Date=datepart(DATEVAR);
DATEVAR is already a date variable. The DATEPART function is appropriate when your incoming variable is a DATETIME, not a DATE.
It is possible that just removing this statement will give you the results you are seeking. To be certain, we would need to see a few examples of the contents of DATEVAR and DATE_CURRENT_STATUS. Or you could just remove the offending statement and see if the results are to your liking. (Of course, the statements that follow would also need a slight adjustment. They would have to work with DATEVAR, instead of DATE.)
... View more