2011 Aug 08 4:08 PM
Dear all
I have to Timestamps (Date and Time) and should calculate the minutes inbetween.
For ex:
IN = 25.07.2011 09:01:20
OUT = 26.07.2011 10:15:30
How Can I calculate the difference between this 2 dates and times? If Possible also with considering the factory calendar.
Is there a FM?
thank you
Herbert
2011 Aug 08 4:56 PM
Hi Herbert,
I've used FM DELTA_TIME_DAY_HOUR in the past. It imports a beginning date and time and an ending date and time and exports the minutes between them.
Brenda
Dear all
I have to Timestamps (Date and Time) and should calculate the minutes inbetween.
For ex:
IN = 25.07.2011 09:01:20
OUT = 26.07.2011 10:15:30
How Can I calculate the difference between this 2 dates and times? If Possible also with considering the factory calendar.
Is there a FM?
thank you
Herbert
2011 Aug 08 4:15 PM
Hi
please use below FM '/SDF/CMO_DATETIME_DIFFERENCE' to calculate time date between two timestamp.
Regards
Rohit
2011 Aug 08 4:17 PM
2011 Aug 08 4:56 PM
Hi Herbert,
I've used FM DELTA_TIME_DAY_HOUR in the past. It imports a beginning date and time and an ending date and time and exports the minutes between them.
Brenda
2011 Aug 08 11:47 PM
Hi Herbert,
the official API (ABAP documentation) to calculate the difference between 2 time stamps is the class CL_ABAP_TSTMP, method SUBTRACT. It calculates a number of seconds.But it doesn't take into account a factory calendar.
So
you'd have to calculate the number of working days using the official DATE_CONVERT_TO_FACTORYDATE function module to convert both dates into day counters, subtract them. For getting the minutes at the lower and upper dates, I think you only need to subtract the time part of each time stamp. One question to ask is what happens if one or both of these 2 dates is not a working day.
So, for your example:
IN = 25.07.2011 09:01:20
OUT = 29.07.2011 10:15:30 (here I added 3 days to your example)
How many minutes between 26.07 and 28.07 : 4320 (3 days * 1440 minutes per day)
How many minutes at IN date : 899 (( 24:00:00 - 09:01:20 ) / 60)
How many minutes at OUT date : 616 (10:15:30 / 60)
PS: Converting a time into seconds is done using implicit type conversion (integer_number_of_seconds = time), and subtracting 2 time data objects returns a number of seconds.
Best regards
Sandra