Application Development and Automation 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: 
Read only

Regarding Date

Former Member
0 Likes
833

hi guys,

i need to create a Date format in this format MM.YYYY ex: 02.2007 but in the data base it shoud store in this format 01.02.2007 ( first day of every month ) and i need to check validation for month MM ( should be 1 to 12 ).

i used it with handling it with sy-datum but i dunt want system or application date, i want user to enter date and when we use sy-datum it default take system date.

i want to even calculate end date of every month i.e for feb 29.02.2007, for march 31.03.2007 and store it in variable.

please can any one give me a piece of code for this because requirement is urgent.

Thanks

pavan kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
768

use FM

CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = sy-datum
IMPORTING
LAST_DAY_OF_MONTH = v_lastdate.

or

call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = g_t_date-begin
IMPORTING
last_day_of_month = g_t_date-end.

to get the last date of a month

6 REPLIES 6
Read only

Former Member
0 Likes
769

use FM

CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = sy-datum
IMPORTING
LAST_DAY_OF_MONTH = v_lastdate.

or

call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = g_t_date-begin
IMPORTING
last_day_of_month = g_t_date-end.

to get the last date of a month

Read only

0 Likes
768

well those FM are kewl, BUT they are not working correctly.

e.G. the last day of February 2007 is the 29th.

both FM´s calculate the 28th.

Read only

0 Likes
768

hi Florian,

last day of February 2007 is 28 only ... it is 29 for 2008 ..

regards,

Santosh

Read only

0 Likes
768

Oh my holy goddess, you ARE right!

Read only

Former Member
0 Likes
768

i´d advice you to use a real date since it would be a hard way to store half a date.

Anyway make yourself a date variable:

DATA lv_date type sy-datum.

write lv_date(2), lv_date(5)+5.

should give you "MM.DDDD".

Read only

Former Member
0 Likes
768

say user entered 102007 on selection screen...

then, V1 = date+0(2).

check whether V1 lies between 01 & 12.

then V2 = date+2(4).

concatenate V1 '01' V2 into final date.

for getting last date use the below....

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = sy-datum

IMPORTING

LAST_DAY_OF_MONTH = v_lastdate.