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

Validate date format

Former Member
0 Likes
2,527

I am getting a date it MMDDYY format, want to check if it is in the right format and then change to normal format. is there any FM for this?

point will be rewarded

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
536

Hi,

Check this...

DATA: v_char(6).

v_char = '121706'.

DATA: v_date TYPE sydatum.

v_date+4(2) = v_char(2).

v_date6(2) = v_char2(2).

CONCATENATE '20' v_char+4(2) INTO v_date(4).

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = v_date

EXCEPTIONS

plausibility_check_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: / 'INvalid date'.

ELSE.

WRITE: / 'Correct date'.

ENDIF.

Thanks,

Naren

3 REPLIES 3
Read only

Former Member
0 Likes
536

Check this FM.

DATE_CHECK_PLAUSIBILITY.

Regards,

Arun.

Read only

Former Member
0 Likes
536

Check this it may help u.

CONVERSION_EXIT_D3DAT_OUTPUT

Regards

Read only

Former Member
0 Likes
537

Hi,

Check this...

DATA: v_char(6).

v_char = '121706'.

DATA: v_date TYPE sydatum.

v_date+4(2) = v_char(2).

v_date6(2) = v_char2(2).

CONCATENATE '20' v_char+4(2) INTO v_date(4).

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = v_date

EXCEPTIONS

plausibility_check_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: / 'INvalid date'.

ELSE.

WRITE: / 'Correct date'.

ENDIF.

Thanks,

Naren