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 Conversions

Former Member
0 Likes
847

Dear All,

I have some problem in solving the date issues can anyone try to solve this problem,

Actually my input is 20.08.1013.,., i need output in the format of 13.10.2008.. Is there any function module

to convert this..,

Thanks,

Thirukumaran. R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
821

Hi

Try out the below mentioned Funciton Module


CONVERT_DATE_TO_INTERNAL

Thanks,

Chidanand

8 REPLIES 8
Read only

bpawanchand
Active Contributor
0 Likes
821

Hi

IT is in the format of YYYYMMDD use OFFSET concept and concatenate the offset value to a string and after that pass it to a variable of type SY-DATUM your problem is solved.

example

DATA :

w_d1 TYPE sy-datum,

w_str TYPE string.

w_d2 TYPE sy-datum VALUE '20.08.1013'.

CONCATENATE w_d20(2) w_d23(2) w_d2+6(4) INTO w_str.

now in w_str the value will be '20081013'.

now assign

w_d1 = w_str .

Regards

Pavan

Read only

0 Likes
821

This message was moderated.

Read only

0 Likes
821

When i execute the following code the output is '13.10.2081'. date and month are right i need year as 2008.,

Recode my codings.,

constants: date type dats value '20081013'.

data : w_d1 TYPE sy-datum,

w_str TYPE string,

w_d2 TYPE sy-datum VALUE date.

CONCATENATE w_d20(2) w_d23(2) w_d2+4(4) INTO w_str.

w_d1 = w_str .

write : / w_d1.

Thanks,

ThiruKumaran. R

Read only

0 Likes
821

Hi

constants: date type dats value '20081013'.
data : w_d1 TYPE sy-datum,
w_str TYPE string,
w_d2 TYPE sy-datum VALUE date.
CONCATENATE w_d2+0(2) w_d2+3(2) w_d2+4(4) INTO w_str.
w_d1 = w_str .
write : / w_d1.

CONCATENATE w_d26(2) w_d24(2) w_d2+0(4) INTO w_str.

Now in w_str you will have date as '13102008'.

Regards

Pavan

Read only

0 Likes
821

Sorry,

my codings is like this,

constants: date type dats value '20.08.1013'.

data : w_d1 TYPE sy-datum,

w_str TYPE string,

w_d2 TYPE sy-datum VALUE date.

CONCATENATE w_d20(2) w_d23(2) w_d2+4(4) INTO w_str.

w_d1 = w_str .

write : / w_d1

Then how to post the message in your format .,.,

Thanks,

Thiru.

Edited by: thirukumaran rajendran on Oct 14, 2008 6:49 AM

Read only

Former Member
0 Likes
822

Hi

Try out the below mentioned Funciton Module


CONVERT_DATE_TO_INTERNAL

Thanks,

Chidanand

Read only

Former Member
0 Likes
821

Hi.

This code may help u.....


PARAMETERS: p TYPE sy-datum DEFAULT sy-datum.
DATA: d TYPE char10 .

WRITE p TO d MM/DD/YYYY.

Read only

Former Member
0 Likes
821

Hi thiru,

When ever you want to print the date the format specified just use the following

Data : a type Sy-datum.

Write:a MM/DD/YYYY.

or Write: DD/MM/YYYY.

or write: YYYY/DD/MM.

Use the above write statement according to your convience.

Cheers!!