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: 

FM to get a date in past

Former Member
0 Kudos

Hi,

Is there any way to get the date corresponding to (current date - 90 days)?

Thanks in Advance,

Savitha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

These FM's might help you.......

DAYS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES_NEW

See a sample code.............

FM to Get the Day for a Particular Date

FM or any other means by which we can get the DAY for a particular date?

Yes, DATE_COMPUTE_DAY

Sample code:

clear: hold_day_of_week.

CALL FUNCTION 'DATE_COMPUTE_DAY'

EXPORTING

DATE = workdate

IMPORTING

DAY = day_of_week_num

EXCEPTIONS

OTHERS = 8.

CASE day_of_week_num.

WHEN 1.

hold_day_of_week = 'Monday'.

WHEN 2.

hold_day_of_week = 'Tuesday'.

WHEN 3.

hold_day_of_week = 'Wednesday'.

WHEN 4.

hold_day_of_week = 'Thursday'.

WHEN 5.

hold_day_of_week = 'Friday'.

WHEN 6.

hold_day_of_week = 'Saturday'.

WHEN 7.

hold_day_of_week = 'Sunday'.

WHEN OTHERS.

hold_day_of_week = 'invalid'.

ENDCASE.

or

You can use DATE_COMPUTE_DAY to get the day number of the week (for example, today gives 5)

then use WEEKDAY_GET which returns an itab with seven entries (one for each day of the week.)

You enter in this itab and get the field langt to get the day name.

Regards,

Pavan

5 REPLIES 5

Former Member
0 Kudos

Hi,

you can use:

data: date like sy-datum.

date = sy-datum - 60.

write: / date.

Regards, Dieter

Former Member
0 Kudos

These FM's might help you.......

DAYS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES_NEW

See a sample code.............

FM to Get the Day for a Particular Date

FM or any other means by which we can get the DAY for a particular date?

Yes, DATE_COMPUTE_DAY

Sample code:

clear: hold_day_of_week.

CALL FUNCTION 'DATE_COMPUTE_DAY'

EXPORTING

DATE = workdate

IMPORTING

DAY = day_of_week_num

EXCEPTIONS

OTHERS = 8.

CASE day_of_week_num.

WHEN 1.

hold_day_of_week = 'Monday'.

WHEN 2.

hold_day_of_week = 'Tuesday'.

WHEN 3.

hold_day_of_week = 'Wednesday'.

WHEN 4.

hold_day_of_week = 'Thursday'.

WHEN 5.

hold_day_of_week = 'Friday'.

WHEN 6.

hold_day_of_week = 'Saturday'.

WHEN 7.

hold_day_of_week = 'Sunday'.

WHEN OTHERS.

hold_day_of_week = 'invalid'.

ENDCASE.

or

You can use DATE_COMPUTE_DAY to get the day number of the week (for example, today gives 5)

then use WEEKDAY_GET which returns an itab with seven entries (one for each day of the week.)

You enter in this itab and get the field langt to get the day name.

Regards,

Pavan

Former Member
0 Kudos

data: date like sy-datum.

date = sy-datum - 90.

write: / date.

Former Member
0 Kudos

Hi Savita,

data: date like sy-datum.

start-of-selection.

date = sy-datum - 90.

write:/ date.

Rewar points for all helpful answers.

kiran.M

0 Kudos

Answered

Thanks,

Savitha