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: 

Get timestamp difference in 9hrs format

Former Member
0 Kudos
153

HI,

I have a requirement where i need to find the timestamp difference and then convert it to 9 hours format. This mean instead of 24hrs a day, i need to consider only 9hrs (working hours only) a day.

I thought of calculating first as 24hours format using Function Module /SDF/CMO_DATETIME_DIFFERENCE (Output for this is number of days and hours), then multiply the result with number 9. Somehow i feel this is not correct as we can get hours result as 17/20/23hrs. when this hours i divide by 9hrs, probably i might get 2 days. which is not correct.

Please help me to resolve this issue. Thank you in advance.

Thansk,

Deepika

1 ACCEPTED SOLUTION

PedroGuarita
Active Contributor
0 Kudos
112

You have to calculate the proportional value.

if 9 hours is considered 100% then the difference you calculated is X, so X = diference * 100 / 9, this way you will have a percentage of a 9 hour day. Then it's the same but with 24, so if 24 is 100% then X hours is percentage you calculated before.

X = 24 * percentage / 100 and you will get the hours proportional to a 24 hour day.

Hope i was clear enough

5 REPLIES 5

Former Member
0 Kudos
112

Can you elaborate further for better understanding.

PedroGuarita
Active Contributor
0 Kudos
113

You have to calculate the proportional value.

if 9 hours is considered 100% then the difference you calculated is X, so X = diference * 100 / 9, this way you will have a percentage of a 9 hour day. Then it's the same but with 24, so if 24 is 100% then X hours is percentage you calculated before.

X = 24 * percentage / 100 and you will get the hours proportional to a 24 hour day.

Hope i was clear enough

0 Kudos
112

Hi Pedro,

Thank you for your reply. But,

I donot want to calculate in terms of percentage. Need to find out difference in 9hours a day instead of 24hrs a day.

Hi Satish,

I need to find the difference of 2 timestamps and convert that to 9 hours a day. For example

Start time stamp = 22/02/2011 13:00:00

End timestamp = 23/02/2011 13:00:00

difference is 24hrs/ 1 day

So final difference is 1 * 9hrs = 9hrs.

Hope this helped you.

Thanks,

Deepika

0 Kudos
112

Hi, I am not sure whether my understanding is right. Please check.

As you have mentioned, if you can use the same function module to find the days and time difference,

For instance:

Date1 is 01.03.2011

Time1 is 13:00:00

Date2 is 02.03.2011

Time2 is 21:00:00

The output of the function module is 1 days and 8 hrs. Convert this to day format. You'll get 1.33 days. Multiply this with your required 9 hrs which in turn will give you 11.97 working hours. Is this is what you are looking for?

0 Kudos
112

Hi Mahalingam,

You are correct. This way it will help me get to 9 hours a day. Thank you very much.

Points are awarded.

Thanks,

deepika