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

Date calculaion

Former Member
0 Likes
1,085

Hi All,

i have one field(char) which have date in format as dd.mm.yyyy.

now i want to add 5 dayes in that field.

i can do it by using concatenate and split. but i want to do it by FM because i need same format as dd.mm.yyyy after calculation.

is there any FM to convert char into date?

Amit.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,060

Why dont you define you field of type sydatum, do all the calculations and then convert it to you required format. It is easier to deal with sydatum type variables

Why dont you define you field of type sydatum, do all the calculations and then convert it to you required format. It is easier to deal with sydatum type variables

8 REPLIES 8
Read only

Former Member
0 Likes
1,061

Why dont you define you field of type sydatum, do all the calculations and then convert it to you required format. It is easier to deal with sydatum type variables

Read only

former_member435013
Active Participant
0 Likes
1,060

Hi,

use CONVERT_DATE_TO_INTERNAL.

Regards

Walter Habich

Read only

Former Member
0 Likes
1,060

Use FMS

"CONVERT_DATE_TO_INTERNAL" or

"CONVERT_DATE_TO_EXTERNAL"

Regards,

Santosh

Read only

Former Member
0 Likes
1,060

'RP_CALC_DATE_IN_INTERVAL'

HR_SEN_CALE_DAYS_DATE

CONVERSION_EXIT_SDATE_OUTPUT

Read only

Former Member
0 Likes
1,060

Hi All,

thanks for your replies.

But i have date value in char field.

i need to convert it into as date type.

Amit.

Read only

Former Member
0 Likes
1,060

When all else fails.. Use a bigger hammer.


DATA: my_cdate(10)   TYPE c VALUE '31.05.2008',
      my_ddate       TYPE d.

write:/ my_cdate.

my_ddate+0(4) = my_cdate+6(4). "YYYY
my_ddate+6(2) = my_cdate+0(2). "DD
my_ddate+4(2) = my_cdate+3(2). "MM

my_ddate = my_ddate + 5.

concatenate my_ddate+6(2)
            my_ddate+4(2)
            my_ddate+0(4) into my_cdate
            separated by '.'.

write:/ my_cdate.

Output


31.05.2008         
05.06.2008         

Read only

Former Member
0 Likes
1,060

Well Paul I did already exactly same as you suggest.

Thank you All.

Amit.

Read only

Former Member
0 Likes
1,060

Hi Jony,

Do as follow...

data : dt_chr(10) TYPE c VALUE '20.05.2008'.    

data : P_DATE TYPE SY-DATUM.

DATA : pa_end TYPE sy-datum.

data: DD(2) TYPE C,
MM(2) TYPE C,
YY(4) TYPE C,
temp_DATE(8) TYPE C.

*DATE1 = SY-DATUM.

DD = dt_chr+0(2).
MM = dt_chr+3(2).
YY = dt_chr+6(4).

CONCATENATE YY mm dd INTO temp_DATE.

p_date = temp_date.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = p_date
days = '05'
months = '00'
signum = '+'
years = '00'
IMPORTING
calc_date = pa_end.

WRITE : pa_end. " Required Date

again use concatenate stmt to make it in dd.mm.yyyy format...

it will give accurate result..

Hope it will solve your problem

Reward points if useful...

Thanks & Regards

ilesh 24x7