Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

My own Function-Module to calculate duration between 2 dates and 2 times

$
0
0

I was searching for a function module that should calculate the duration of 2 tasks .

 

Import Parameter:

DATE_FROM

DATE_TO

TIME_FROM

TIME_TO

 

As result I need values separated into

YEARS

MONTHS

DAYS

HOURS

MINUTES

SECONDS

 

 

Most standard function deliver only one(1) result and than this return value is from type F (floating number, like 2,34546787E-03) and I did not want to convert the result into integer. Other standard functions look like they could work, but when I checked them I found that they where calculation wrong!

 

So I came to the conclusion to copy+paste what ever I can and I wrote my own function module using the SAP function module 'L_TO_TIME_DIFF' 

Here it is (check attachment)

 

 

Please comment if you find a BUG, I will try to solve it.

 

 

 


Germany, 16.01.2016

Jörg Sauterleute

 

 

----

UPDATE, 17.01.2016

I found and error and replaced attachment/coding...


UPDATE, 22.01.2016

another bug found (seconds where wrong when time_to < time_from)

 

UPDATE, 28.01.2016

next bug with time (seconds where wrong, when date_to = date_from AND time_to < time_from) :-P


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>