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 : Funtion Module

Former Member
0 Likes
1,038

Hi,

is there any function module available which converts the date into american standard.

e.g. user will pass the date ( 32406 mmddyy ) but they might pass the date "31506" instead of 031506. so it should get converted into 03152006.

pls suggest.

Thanx

Hi,

is there any function module available which converts the date into american standard.

e.g. user will pass the date ( 32406 mmddyy ) but they might pass the date "31506" instead of 031506. so it should get converted into 03152006.

pls suggest.

Thanx

8 REPLIES 8
Read only

abdul_hakim
Active Contributor
0 Likes
1,004

Use the FM CONVERT_DATE_TO_EXTERNAL.

Cheers,

Abdul

Read only

Former Member
0 Likes
1,004

move that date to another variable of type n.

data: date1(6) type n.

data: new_date(8).

date1 = '31506'.

concatenate date1+0(4)

'20'

date1+4(2)

into new_date.

write: new_date.

Regards,

Ravi

Read only

0 Likes
1,004

Quick sample.



report zrich_0001.

data: date_in(6) type c value '31506'.
data: date_out(10) type c.
data: n(6) type n.
data: d type sy-datum.

n = n + date_in.

d+4(4) = n+0(4).
d+2(2) = n+4(2).
if d+2(2) < 50.
  d+0(2) = '20'.
else.
  d+0(2) = '19'.
endif.

call function 'CONVERT_DATE_TO_EXTERNAL'
     exporting
          date_internal = d
     importing
          date_external = date_out.


write:/ date_out.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,004

HI,

write these lines..

Data: Date like sy-datum,

date1 like sy-datum,

date2(10).

lets say your first date is DATE .. so user enters the date like <b>'31506'</b>, write the code as

Move: Date to DATE1.

write: DATE1 to DATE2.

so the DATE2 will have the User format Date, i mean user format is american then date will appear in American Format, if the User date is in German , then date output will appear in the German format

http://www.sap-basis-abap.com/sapab015.htm

Thanks

Sudheer

Read only

Former Member
0 Likes
1,004

Hi Abdul,

Thanks for reply.

I have already tried this FM but i want to pass value 32406 instead of 032406.. and if you pass this value it does not work.

Read only

0 Likes
1,004

There is no standard FM exists for this purpose..

Cheers,

Abdul hakim

Read only

Former Member
0 Likes
1,004

thanks ravi but i am already using concatenate statement to resolving this issue and it is working properly but I want to use system standard function module.

any idea?

Read only

0 Likes
1,004

There is no standard function module that does that. You have to manually ensure that the leading zero is also there.