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 the previous date

Former Member
0 Kudos
9,439

Hi

Pls tell me to get the previous date of the the date.

Thanx in advance,

Parvez.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
2,127

Hi Venu,

Use this Function Module

data: prev_date like (type of calc_date).

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = sy-datum

days = 1

months = 0

signum = '-'

years = 0

IMPORTING

calc_date = prev_date.

This should surely work.

Thanks and Regards,

Prashanth

8 REPLIES 8

suresh_datti
Active Contributor
0 Kudos
2,127

data w_date type sy-datum.

w_date = w_date - 1.

write: / w_date. "yetserday

~Suresh

Former Member
0 Kudos
2,127

u can subtract 1 from present date

previous_date = present_date - 1.

Former Member
0 Kudos
2,127

hi,

No need of any fm.

Just subtract the no of the days from the days. It gives the previous date.

Regards,

Sailaja/.

RichHeilman
Developer Advocate
Developer Advocate
2,127

Simply subtract from today.


data: yesterday type sy-datum.

yesterday = sy-datum - 1.

Regards,

Rich Heilman

Former Member
0 Kudos
2,128

Hi Venu,

Use this Function Module

data: prev_date like (type of calc_date).

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = sy-datum

days = 1

months = 0

signum = '-'

years = 0

IMPORTING

calc_date = prev_date.

This should surely work.

Thanks and Regards,

Prashanth

uwe_schieferstein
Active Contributor
0 Kudos
2,127

Hello Venu

If you also need function modules dealing with <b>working days</b> you will find useful FMs in function group <b>FB00</b>.

Regards

Uwe

abdul_hakim
Active Contributor
0 Kudos
2,127

Hi,

Use the below logic,

data lastdate like sy-datum.

lastdate = sy-datum - 1.

Cheers,

Abdul Hakim

Former Member
0 Kudos
2,127

Hi Venu,

Check,

REPORT Z13708_TEST11 .

data : s_date type sy-datum.

data : s_table type table of CASDAYATTR with header line .

start-of-selection.

CALL FUNCTION 'DAY_ATTRIBUTES_GET'

  • EXPORTING

  • FACTORY_CALENDAR = ' '

  • HOLIDAY_CALENDAR = ' '

  • DATE_FROM = s_date

  • DATE_TO = SY-DATUM

  • LANGUAGE = SY-LANGU

  • IMPORTING

  • YEAR_OF_VALID_FROM =

  • YEAR_OF_VALID_TO =

  • RETURNCODE =

TABLES

DAY_ATTRIBUTES = s_table

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

s_date = s_table-date - 1.

write : s_date.

Regards,

Azaz.