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: 

How to - get first DAY of the month from the date ?

Former Member
12 REPLIES 12

Former Member
0 Kudos

Hi..,

move '01' to the day characters of the date field...

Execute this code...

<b>parameters Date type sy-datum default '20071203'.

move '01' to date+6(2).

write date.</b>

reward all helpful answers!!

sai ramesh

former_member533584
Contributor
0 Kudos

Hi,

parameters w_date like sy-datum .

w_date+6(2) = '01'.

write w_date. " first date

Message was edited by:

ananth

Former Member
0 Kudos

hi,

chk out this fm

WEEK_GET_FIRST_DAY

thanks,

Navneeth

Former Member
0 Kudos

U can also use the function module

<b>BKK_GET_MONTH_LASTDAY</b>, pass any date of the previos month, u'll get the last of the previous month and add 1 to the date returned by the fm to get the first DAY of the current month.

Message was edited by:

Rajesh

Former Member
0 Kudos

Former Member
0 Kudos

if you have the date var..

data : date like sy-datum value '20070405'.

concatenate date+0(6) '01' into date.

regards

shiba dutta

Former Member
0 Kudos

Hi,

DATA: ultimo TYPE d.

ultimo      = sy-datum. 
ultimo+6(2) = '01'.          " = first day of this month

Regards

Sudheer

Former Member
0 Kudos

hi,

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.

************************************

(OR)

Try..

DATA:DAYNR LIKE HRVSCHED-DAYNR,

DAYTXT LIKE HRVSCHED-DAYTXT,

DAYFREE LIKE HRVSCHED-NODAY.

DATA:LANGU LIKE SY-LANGU ,

DATE LIKE SY-DATUM,

CALID LIKE P1027-CALID VALUE 'US'.

date = sy-datum.

date+6(2) = 01. "----->to get the first day .

*first day of the month

write:/ 'First date of the month', date.

*Day name

CALL FUNCTION 'RH_GET_DATE_DAYNAME'

EXPORTING

langu = SY-LANGU

date = DATE

CALID = CALID

IMPORTING

DAYNR = DAYNR

DAYTXT = DAYTXT

DAYFREE = 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:/ DAYTXT.

Don't forget to reward if useful....

Former Member
0 Kudos

refer below code,



DATA: currDate TYPE d.

currDate      = sy-datum.

*write  : 'befor ' , currDate.

currDate+6(2) = '01'.

*write  😕 'after ' , currDate.

currDate      = currDate.

WRITE: / 'first day of month' , currDate.

*
*ULINE.
*
*currDate      = sy-datum.
*
*write  : 'befor ' , currDate.
*
*currDate+4(2) = currDate+4(2) + 1.
*
*currDate+6(2) = '01'.
*
*write: / 'after one month ' , currDate.

reward if useful

Former Member
0 Kudos

Hi,

Try this.

data g_first_day type sy-datum.

g_first_day = sy-datum.

g_first_day+6(2) = '01'.

Will change to first day of present month.

Hope this will help.

Jogdand M B

Former Member
0 Kudos

Hi palaniappan,

Use this code.

parameters :

p_reqdat type d.

data:

w_futrdate type d,

w_chtext(8) type c.

w_chtext = p_reqdat.

w_chtext+6(2) = '01'.

w_futrdate = w_chtext.

write ' The First Day of Next Month is '(001).

write w_futrdate dd/mm/yyyy.

Rewar if helpful.

Regards,

Satish

former_member206072
Discoverer
0 Kudos

This message was moderated.