Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get day interval between two dates?

raffinkira
Participant
0 Kudos

Hi all,

Suppose that I have two timestamps, e.g., 20220901225421 and 20220830221056, I want to get how many days between these two date.

The logic is simple, just make it 20220901000000 and 20220830000000, so the interval should be 2 days.

Is there any function or class that I can use?

Regards,

Eric

2 REPLIES 2

FredericGirod
Active Contributor

if you take only the day part you could do directly the calcul

renato_martins
Participant

You can take the first 8 characters of each information and do a simple subtraction to return the difference

days = dat_1 - dat_2.

Or you can use the cl_abap_tstmp=>subtract method which will return the difference in seconds