Application Development 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: 

date conversion

Former Member
0 Kudos

HI Expert,

I am using erdat filed from proj table. Want to convert user date range format viz ''ddmmyyy '' to '''yyymmdd'' .

Please suggest a conversion exit for the same.

Tx

Kshitija

8 REPLIES 8

abdulazeez12
Active Contributor
0 Kudos

Hi

use

DATA: V_DATE LIKE SY-DATUM,

V_DATE2(10).

CALL FUNCTION 'CONVERT_DATE_INPUT'

EXPORTING

INPUT = '21102002' "DD.MM.YYYY

PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = V_DATE "YYYY.MM.DD

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

WRONG_FORMAT_IN_INPUT = 2

OTHERS = 3.

V_DATE2 = V_DATE.

WRITE:/ V_DATE2.

0 Kudos

tx for the info,

How iwll this work for range of date viz 20012007 to 10092007?

Former Member
0 Kudos

Hi,

You can do it using EDIT MASK, check out F1 hep for the same or find the conversion exit attached to the field by going to domain of the field and you can use it with WRITE statement.

Regards,

Raghavendra

Former Member
0 Kudos

Hi,

In this code you can interchange the location of the year,day and month fields as required.

DATA: date LIKE sy-datum,

changedate(10) TYPE c.

DATA: BEGIN OF it_date1, " To accept date into a internal table

yyyy(4),

mm(2),

dd(2),

END OF it_date1.

DATA: BEGIN OF it_date2, " Internal table for dd/mm/yyyy format

dd(2),

mm(2),

yyyy(4),

END OF it_date2.

DATA: BEGIN OF it_date3, " Internal table for mm/dd/yyyy format

mm(2),

dd(2),

yyyy(4),

END OF it_date3.

date = sy-datum.

it_date1 = date.

MOVE-CORRESPONDING it_date1 TO: it_date2,it_date3.

WRITE it_date2 TO changedate USING EDIT MASK '__/__/____'. " dd/mm/yyyy

WRITE:/ 'Date in dd/mm/yyyy format',

/ changedate.

SKIP.

CLEAR changedate.

WRITE it_date3 TO changedate USING EDIT MASK '__/__/____'. " mm/dd/yyyy

WRITE:/ 'Date in mm/dd/yyyy format',

/ changedate.

Thanks.

Former Member
0 Kudos

Hi,

You can use CONCATENATE statement to do the same ...

Former Member
0 Kudos

hi ..

try using FM, CONVERT_DATE_TO_INTERNAL and the output will be of the yyyymmdd format....

regards,

ritika

Former Member
0 Kudos

Hi,

Use can Use the FM " convert_date_to_internal".

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = ws_date ( date to be converted)

IMPORTING

DATE_INTERNAL = ws_date1

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2

.

Reward if Useful.

Regards,

Chitra

Former Member
0 Kudos

If you are using it in write statement,

write : using edit mask.

else

'CONVERT_DATE_TO_INTERNAL'

for amny records.

loop at records.

call 'CONVERT_DATE_TO_INTERNAL'

enloop.