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

Function CONVERT_DATE_TO_INTERNAL

Former Member
0 Likes
14,118

Hi there,

I am using function CONVERT_DATE_TO_INTERNAL and am confronted with an error at:

   CALL 'DATE_CONV_EXT_TO_INT'
       ID 'DATINT' FIELD h_date_internal
       ID 'DATEXT' FIELD h_date_external.

I am passing external date value 20130101 and receiving nothing back.

When i pass any 2012 date, e.g 20121212 the conversion results in internal date value 12121220.

Has anyone attempted to use this function for 2013 dates yet?

1 ACCEPTED SOLUTION
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
8,024

The internal date format is YYYYMMDD. The value you are passing -  20130101 - is already in the internal format. You can see exception DATE_EXTERNAL_IS_INVALID being raised by the FM.

Try passing 01012013 or 01.01.2013 and you will get the correct result.

6 REPLIES 6
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
8,025

The internal date format is YYYYMMDD. The value you are passing -  20130101 - is already in the internal format. You can see exception DATE_EXTERNAL_IS_INVALID being raised by the FM.

Try passing 01012013 or 01.01.2013 and you will get the correct result.

Read only

Former Member
0 Likes
8,024

Hi Please Specify the Correct Date Formate.

I have Done what you have mentioned and its working fine Withoout any Problem.

Kindly Check Your input to the Fm.

Regards,

Amit

Read only

vinoth_aruldass
Contributor
0 Likes
8,024

hi,

SAP's internal date format is YYYYMMDD so the functional module you are using is for converting any format to internal. So be clear about your input.

Hope it helps,

Vinoth

Read only

Former Member
0 Likes
8,024

Hello Brendan,

   Kindly correct your date format, If you pass the Date in YYYYMMDD format then it will give error as this FM itself convert Date in internal format YYYYMMDD. You could either try 01012013 or 01/01/2013 or any format other that YYYYMMDD.

Chk below screen shot.

rgds,

Deepti

Read only

Former Member
0 Likes
8,024

Hello frnd,

try this out...it works...!

************CONVERT DATE FORMAT FROM YYYMMDD TO DDMMYYY**********************
DATA: YY(4) TYPE C,
       DD(2) TYPE C,
       MM(2) TYPE C.
DATA: DATE2(10) TYPE C.

DD = SY-DATUM+6(2).
MM = SY-DATUM+4(2).
YY = SY-DATUM(4).

CONCATENATE DD MM YY INTO DATE2 SEPARATED BY '.'.

Read only

Former Member
0 Likes
8,024

Thank you for the swift responses.

You are correct, we were previously using HTML and therefore we had to perform the date validation check at the module level so we were passing through the internal date in this format and effectively validating twice.

It is interesting because we have used this module for many years and it does not occur until 2013 as it views 13 as an invalid month whereas it viewed the 12 in 2012 as the month and would therefore pass back 12121220 (itself an incorrect date!).

Again, thanks for the advice.