cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the first day of current month

Former Member
0 Kudos

hi guys,

i am trying to get the first day of current month which get from the date i input at the selection screen. my method is not so good, so i was wondering if there is better way to get the this,

thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this .

data : DAYNR LIKE HRVSCHED-DAYNR,

DAYTXT LIKE HRVSCHED-DAYTXT.

data langu like sy-langu value 'EN'.

Parameters PDATE LIKE SY-DATUM.

PDATE+6(02) = '01'.

.

CALL FUNCTION 'RH_GET_DATE_DAYNAME'

EXPORTING

LANGU = LANGU

DATE = PDATE

  • CALID =

IMPORTING

DAYNR = DAYNR

DAYTXT = DAYTXT

  • DAYFREE =

  • EXCEPTIONS

  • NO_LANGU = 1

  • NO_DATE = 2

  • NO_DAYTXT_FOR_LANGU = 3

  • INVALID_DATE = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

WRITE 😕 PDATE, DAYNR, DAYTXT.

Cheers

Former Member
0 Kudos

Sanjay,

Guess the requirement was to get the DAY and not just the DATE. If you see the answer that I have give that is the same thing that I have suggested.

Regards,

Ravi

Former Member
0 Kudos

hi,Ravikumar,

it is me should say sorry to you, i mis-use "date" & "day", Sanjay's answer is what i want. but thank you all the same, i also tried the function you mentioned, it is useful, it would be in use in the future.

and thanks Sanjay.

Former Member
0 Kudos

Parameters PDATE LIKE SY-DATUM.

PDATE+6(02) = '01'.

=======================================

this part is enough, sorry to bring you two guys the trouble and raise a so simple question.

thank you.

Answers (1)

Answers (1)

Former Member
0 Kudos

Adamyam,

You have system date with you, replace just the date with 01 and then use the function module DATE_TO_DAY to get the first day of the month.

Hope this helps.

Regards,

Ravi

Note : Please reward points if this helps you.