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 Conversion

Former Member
0 Likes
1,503

Hello Gurus,

I have one probelm with conversion of the date.

PDATE1 TYPE D.

PDATE1 = SY-DATUM.

WRITE : PDATE1.

my problem is SY-DATUM = 17.01.2007 and i am getting pdate1 is 17012008.

any method or function module is there to convet 17012008 to 17.01.2008.

Thanks in advance.

Best Regds,

zubera

16 REPLIES 16
Read only

Former Member
0 Likes
1,480

Use

WRITE PDATE1 USING EDIT MASK '__.__.____'.

Vinodh Balakrishnan

Read only

Former Member
0 Likes
1,480

Hi,

One way is by manually converting it.

Take a variable of type c length 10.

Now your date is in the format 17012008.

Now write the following code :

DATA: d_date(10) TYPE c.

CONCATENATE sy-datum+0(2) d_date INTO d_date.

CONCATENATE d_date '.' INTO d_date.

CONCATENATE d_date sy-datum+2(2) INTO d_date.

CONCATENATE d_date '.' INTO d_date.

CONCATENATE d_date sy-datum+4(4) INTO d_date.

I think this will help.

Regards,

Sagar

Read only

Former Member
0 Likes
1,480

Hello Vinod ,

Thanks for your reply.

my problem is i dont want to write the date formate.

i want to input the date formate in the BDC screen.

I want to take PDATE1 = SY-DATUM and input in the form '17.01.2008' BDC Screen.

Thanks in advance.

best regds,

zub

Read only

Former Member
0 Likes
1,480

data : date(10) type c value '01122004'.

write 😕 date using edit mask '__/__/____'.

output is : 01.12.2004.

Read only

Former Member
0 Likes
1,480

Try using the function module:

CONVERT_DATE_TO_EXTERNAL

Read only

Former Member
0 Likes
1,480

Hi,

Ignore my first reply.

Try this out

Take a variable of type c length 10.

Now your date is in the format 17012008.

Now write the following code :

DATA: d_date(10) TYPE c.

CONCATENATE pdate1+0(2) d_date INTO d_date.

CONCATENATE d_date '.' INTO d_date.

CONCATENATE d_date pdate1+2(2) INTO d_date.

CONCATENATE d_date '.' INTO d_date.

CONCATENATE d_date pdate1+4(4) INTO d_date.

It works Please try it out.

Regards,

Sagar

Read only

Former Member
0 Likes
1,480

Thanks for your reply.

it is not working . it is giving in some other formate.

Read only

Former Member
0 Likes
1,480

Try the function module. Are you sure your sy-datum is in th eformat 17.01.2008, if pdate1 is in the format 17012008. Because I assigned the value 17012008 to pdate1 and it works.

Can you please confirm the formats again by debugging.

Regards,

Sagar

Read only

Former Member
0 Likes
1,480

Hi Sagar,

Thanks for your reply.

SY-DATUM formate is 17.01.2008.

PDATUM TYPE D.

PDATUM = SYDATUM.

Insteade of stroring PDATU as 17.01.2008 it stores 17012008.

So i want to take the sy-datum field in the formate 17.01.2008 and enter in to input screen of BDC.

Read only

RemiKaimal
Active Contributor
0 Likes
1,480

Hi,

Instead of the type D, you should have used sy-datum.

Your problem can be solved with CONVERT_DATE_TO_EXTERNAL.

FYI :

Check out this code :

DATA:

v_date LIKE sy-datum,

v_date_o(10).

v_date = sy-datum.

WRITE : / 'Today : ' , v_date.

CALL FUNCTION 'DATE_STRING_CONVERT'

EXPORTING

date_format = '1'

date_string = sy-datum

IMPORTING

result_date = v_date.

v_date_o = v_date.

WRITE:/ 'Converted : ', v_date_o.

Where date_format takes :

1 - DD.MM.YYYY

2 - MM/DD/YYYY

3 - MM-DD-YYYY

4 - YYYY.MM.DD

5 - YYYY/MM/DD

6 - YYYY-MM-DD

Also check out the Function module :

CONVERT_DATE_TO_INTERNAL

Regards,

Remi

Plz reward points if useful

Read only

Former Member
0 Likes
1,480

it is giving same formate which i mentioned earlier. 01172008.

I think it is not working acording to my requirement.

Read only

0 Likes
1,480

Hi,

declare pdatum like:

pdatum TYPE dats..

regards,

Renjith Michael.

Read only

Former Member
0 Likes
1,480

ya exactly now it is working fine.

thanks.

Read only

Former Member
0 Likes
1,480

Hello Michel,

It si working fine when output.

But again problem when giving input to BDC screen field. it take same formate of 20081701.

Pleasse let me know any method is there to change.

Read only

0 Likes
1,480

Hi,

Before bdc do it like:

DATA: date_string(10) TYPE c.

data : date_c(2) type c, month_c(2) type c, year_c(4) type c, e(20) type c, f(30) type c.

date_c = pdatum+6(2).

month_c = pdatum+4(2).

year_c = pdatum+0(4).

concatenate date_c '. ' month_c '. ' year_c into date_string .

and pass this date_string to your BDC.

Regards,

Renjith Michael.

Edited by: Renjith Michael on Jan 17, 2008 5:16 PM

Read only

Former Member
0 Likes
1,480

ya exactly i have hard coded and it is working fine.

thanks