- SAP Community
- Groups
- Interest Groups
- Application Development
- Discussions
- Get timestamp difference in 9hrs format

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.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Get timestamp difference in 9hrs format

Former Member

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Feb 28 9:44 AM

153

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 01 11:36 AM

112

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 01 11:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 01 11:36 AM

113

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 02 4:20 AM

112

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 02 9:48 AM

112

- SAP Managed Tags:
- ABAP Development

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2011 Mar 03 3:50 AM

112

- SAP Managed Tags:
- ABAP Development

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