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: 

Dates and Intervals

Former Member
0 Kudos

Hi all,

1) I wish to attain the interval for a pair of dates (e.g. 20 Jan 2007 and 27 Jan 2007). It should result me with 7 days.

2) There is a given number of days (e.g. 3 days), and also a starting date (9 Feb 2007). It should result me with 14 Feb 2007 since 10 Feb and 11 Feb are non-working days. Is there any function module to perform the above?

Many thanks and regards,

Patrick

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

1) Simple substraction would do.

v_diff = date2 - date1. 'V-diff should be of int type.

2)use the fm K_ABC_WORKDAYS_FOR_PERIODS_GET

5 REPLIES 5

Former Member
0 Kudos

hi Patrik,

Date :

DATE_COMPUTE_DAY : Returns weekday for a date

DATE_GET_WEEK : Returns week for 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.

MONTH_NAMES_GET : Get the names of the month

WEEK_GET_FIRST_DAY : Get the first day of the week

HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format

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

Regards,

Santosh

former_member181962
Active Contributor
0 Kudos

1) Simple substraction would do.

v_diff = date2 - date1. 'V-diff should be of int type.

2)use the fm K_ABC_WORKDAYS_FOR_PERIODS_GET

Former Member
0 Kudos

Hi Patrick,

1) Just define a variable of type i and subtract the two days.

2) Use FM DATE_CONVERT_TO_FACTORYDATE

DATA:

zlv_days TYPE i,

zlv_workday TYPE c.

ev_date = iv_date.

zlv_days = iv_days.

WHILE zlv_days GT 0.

ev_date = ev_date + 1.

CLEAR:

zlv_workday.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

date = ev_date

factory_calendar_id = iv_fabkl

IMPORTING

workingday_indicator = zlv_workday

EXCEPTIONS

calendar_buffer_not_loadable = 1

correct_option_invalid = 2

date_after_range = 3

date_before_range = 4

date_invalid = 5

factory_calendar_not_found = 6

OTHERS = 7.

IF syst-subrc <> 0.

EXIT.

ENDIF.

IF zlv_workday = space.

SUBTRACT 1 FROM zlv_days.

ENDIF.

ENDWHILE.

Regards,

John.

Former Member
0 Kudos

hi,

use the following FM

RP_CALC_DATE_IN_INTERVAL

RP_LAST_DAY_OF_MONTHS

SD_DATETIME_DIFFERENCE

Former Member
0 Kudos

Thanks dude!