Application Development and Automation 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: 
Read only

Regarding 'Difference Between Two Dates in Days' - Urgent

Former Member
0 Likes
1,365

Hi,

How to find difference between two specified dates. I tried to use function module

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = start

i_datum_von = end

i_kz_excl_von = '0'

i_kz_incl_bis = '1'

IMPORTING

e_tage = days.

But its giving wrong answers.

For example :

This function module giving 30 days as output for both dates,

01.10.2007 to 31.10.2007 ( wrong, it should give 31 days)

and

01.11.2007 to 30.11.2007

Is there any other func to find this? Can anyone help me?

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,126

Hi

Why you need a fun module for this purpose

it is a simple operation

to find difference between two specified dates

declare a variable

data days type i

days = date2 - date1.

it straight away gives the correct days

no need of fun module any more

Reward points for useful Answers

Regards

Anji

Hi,

How to find difference between two specified dates. I tried to use function module

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = start

i_datum_von = end

i_kz_excl_von = '0'

i_kz_incl_bis = '1'

IMPORTING

e_tage = days.

But its giving wrong answers.

For example :

This function module giving 30 days as output for both dates,

01.10.2007 to 31.10.2007 ( wrong, it should give 31 days)

and

01.11.2007 to 30.11.2007

Is there any other func to find this? Can anyone help me?

Thanks in Advance.

6 REPLIES 6
Read only

Former Member
0 Likes
1,127

Hi

Why you need a fun module for this purpose

it is a simple operation

to find difference between two specified dates

declare a variable

data days type i

days = date2 - date1.

it straight away gives the correct days

no need of fun module any more

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
1,126

Hi Siva,

Try this,

DATA : DATE1 LIKE SY-DATUM,

DATE2 LIKE SY-DATUM,

DAYS1 TYPE I.

DATE1 = '01012005'.

DATE2 = SY-DATUM.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = DATE1

endda = DATE2

IMPORTING

DAYS = DAYS1

  • WEEKS = WEEKS1

  • MONTHS = MONTHS1

  • YEARS = YEARS1.

write : days1.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,126

Hi Siva,

The easiest way is to declare two variables of type sy-datum and populate the twoo variables.

You'll know which variable contains the higher date.

Subtract the lower variable from the higher variable and you get to know the number of days.

Divide it by 365 to get interms of the number of years.

This logic I used in one of my reports.

Hope this solves your query.

Reward Points if useful.

Thanks,

Tej..

Read only

Former Member
0 Likes
1,126

hi,

You can FIMA_DAYS_BETWEEN_TWO_DATES_2 and use the parameters

I_DATUM_VON --> start date

I_DATUM_BIS --> end date

I_STGMETH --> 2 (this parameter is to determin the number of days in a year. I advise to use 2)

<b>Reward points</b>

regards

Read only

Former Member
0 Likes
1,126

Hi Siva,

Use this FM : HR_99S_INTERVAL_BETWEEN_DATES

instead of DAYS_BETWEEN_TWO_DATES

Reward Points for helpful answers.

Thanks.

Hari krishna

Read only

Former Member
0 Likes
1,126

Answered. Thanks to all.