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: 

How to calculate number of days in ABAP?

Former Member
0 Kudos

Hi,

I have a condition as below:

If (field1 - field2) > 12 Months

E.g field1 = 31.05.2011 & field2 = 10.11.2011

Can SAP actually minus dates and check if the difference is greater than 12 months?

How do I perform this calculation?

Pls advice.

Thanks!

Moderator message : Date FAQ, duplicate post. Thread locked.

Edited by: Vinod Kumar on Mar 2, 2012 1:50 PM

5 REPLIES 5

Aashish28
Contributor
0 Kudos

Use this FM - HR_99S_INTERVAL_BETWEEN_DATES and apply conditions as per your requirement.

Former Member
0 Kudos

Hi,

Try this function modules:

MONTHS_BETWEEN_TWO_DATES

HR_AUPBS_MONTH_DAY

Regards,

iostreamax

former_member76372
Participant
0 Kudos

Hi,

If your calculating dates please do not manually calculate it like that.

You need to determine like week numbers, month and days.

The best way to do it is by using FM related to dates. Play around with these FMs in your program:

Function Modules related to Date and Time Calculations

CALCULATE_DATE - Calculates the future date based on the input .

DATE_TO_DAY - Returns the Day for the entered date.

DATE_COMPUTE_DAY - Returns weekday for a date

DATE_GET_WEEK - Returns week for a date

RP_CALC_DATE_IN_INTERVAL - Add days / months to a date

DAY_ATTRIBUTES_GET - Returns attributes for a range of dates specified

MONTHS_BETWEEN_TWO_DATES - To get the number of months between the two dates.

END_OF_MONTH_DETERMINE_2 - Determines the End of a Month.

HR_HK_DIFF_BT_2_DATES -Find the difference between two dates in years, months and days.

FIMA_DAYS_AND_MONTHS_AND_YEARS - Find the difference between two dates in years, months and days.

WEEK_GET_FIRST_DAY - Get the first day of the week

SD_CALC_DURATION_FROM_DATETIME - Find the difference between two date/time and report the difference in hours

L_MC_TIME_DIFFERENCE - Find the time difference between two date/time

HR_99S_INTERVAL_BETWEEN_DATES - Difference between two dates in days, weeks, months

LAST_DAY_OF_MONTHS - Returns the last day of the month

DATE_CHECK_PLAUSIBILITY - Check for the invalid date.

DATE_2D_TO_4D_CONVERSION - Year entry: 2-character to 4-character.

DAY_IN_WEEK - Input date and will give the name of the day 1-monday,2-Tuesday....

SD_DATETIME_DIFFERENCE - Give the difference in Days and Time for 2 dates

Former Member
0 Kudos

Hi

use this FM HR_AUPBS_MONTH_DAY

Former Member
0 Kudos

Hi,

please check below FM

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

I_DATE_FROM = FROMDATE

I_DATE_TO = TODATE

IMPORTING

E_DAYS = EDAYS.

  • E_MONTHS = EMONTHS

  • E_YEARS = EYEARS.

Regards,

Sateesh.