cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with date calculation

Former Member
0 Kudos
145

I am a rookie in SAP i have a small problem with date.Do we have any function module to find out the first day in a month if we give out the system current date ?? Pls help me out.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Easiest way is

wrk_date = sy-datum

wrk_date+6(2) = '01'.

pass wrk_date to FM DATE_TO_DAY..

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

As Ganesan told,you can do.

Here is the sample code.

data v type sy-datum.

data d type DTRESR-WEEKDAY.

v+6(2) = '01'.

v4(2) = sy-datum4(2).

v0(4) = sy-datum0(4).

CALL FUNCTION 'DATE_TO_DAY'

EXPORTING

date = v

IMPORTING

WEEKDAY = d.

write d.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try this:

data: wa_day(9) type c,
      wa_date type sy-datum.

      wa_date = sy-datum.
      wa_date+6(2) = '01'.

call function 'DATE_TO_DAY'
  exporting
    date          = wa_date
  IMPORTING
    WEEKDAY       = wa_day
          .

write: / 'First day of this month is', wa_day, wa_date.

Regards,

Ville

Former Member
0 Kudos

remember one thing with date you can do manipulation like -n or +n

n = 1,2,3........

it will delete n days or add n days.

hope the tip help. FM i can't say, but go to se37 type date and press F4, if any FM is there , system will show

regards.

Former Member
0 Kudos

most easiest way...

concatenate sy-datum(4) '01' into date1.