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

Enter a valid value

Former Member
0 Likes
2,383

Hi!

I get the message "Enter a valid date ".

Whats wrong ?

Can u please help. Or do you know another FM

for such purposes ?

I must be able to populate various date formats

e.g 04/24/2007, 04-24-2007 .....

Regards

sas

data s type sy-datum.
*04/24/2007

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = '04/24/2007'
 IMPORTING
    DATE_INTERNAL                  = s
          .
write s.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,537

Hi,

data : date(10) type c value '31'.01.2008'm,
                   s type sy-datum.
 
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = date
 IMPORTING
    DATE_INTERNAL                  = s
          .

Regards,

Morris Bond.

Reward Points if helpful.

Edited by: Morris Bond on Mar 27, 2008 2:24 PM

7 REPLIES 7
Read only

Former Member
0 Likes
1,537

you need to external, not to internal.

internal date format is yyyymmdd (8 characters).

Read only

Former Member
0 Likes
1,537

Hi,

Give the dates without the slash .

Remove '/'

Reward if helpful.

Regards.

Read only

Former Member
0 Likes
1,537

HI

USE THE FOLLOWING CODE

DATA: W_DATE TYPE CHAR10.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = W_DATE

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2

.

WRITE: W_DATE.

Read only

dhruv_shah3
Active Contributor
0 Likes
1,537

Hi,

Write date in YYYY-MM-DD format

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
1,538

Hi,

data : date(10) type c value '31'.01.2008'm,
                   s type sy-datum.
 
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = date
 IMPORTING
    DATE_INTERNAL                  = s
          .

Regards,

Morris Bond.

Reward Points if helpful.

Edited by: Morris Bond on Mar 27, 2008 2:24 PM

Read only

Former Member
0 Likes
1,537

Dear All this is not what Im asking

I need a solution whereby I can

input exactly either

04/24/2007 or 04-24-2007 or 24/04/2007

and getting

as output -> YYYYMMDD

Regards

sas

Read only

0 Likes
1,537

Hi Erdam,

Go through this simple code, i have not used any function module for date conversion.

PARAMETERS:

p_date(10) TYPE c.

DATA w_date(8) TYPE c.

w_date0(4) = p_date6(4).

IF p_date0(2) > 12 OR p_date3(2) LE 12.

w_date4(2) = p_date3(2).

w_date6(2) = p_date0(2).

ELSEIF p_date0(2) LE 12 OR p_date3(2) > 12.

w_date4(2) = p_date0(2).

w_date6(2) = p_date3(2).

ENDIF.

WRITE w_date.

best regards

Anup.