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: 

Convert date format YYYYMMDD to DD.MM.YYYY

Former Member
0 Kudos

hi

i was wondering is there a FM which convert date format YYYYMMDD to DD.MM.YYYY

instead of u know cutting the YYYY and MM and DD and concatement them again

1 ACCEPTED SOLUTION

rainer_hbenthal
Active Contributor

write sy_datum to var_c_10 DD/MM/YYYY.

13 REPLIES 13

rainer_hbenthal
Active Contributor

write sy_datum to var_c_10 DD/MM/YYYY.

Former Member

Hi,

You can use FM CONVERSION_EXIT_PDATE_OUTPUT. This will always convert from system format (YYYYMMDD) to actual user format (whatever set for the user, actually using the program).

Hope this will help.

Regards,

Nitin.

0 Kudos

Thanks, this works 🙂

0 Kudos

Harshit Agrawal Why not using the official and documented feature:

write sy_datum to var_c_10.

(without DD/MM/YYYY means the current user date format)

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi ,

See this piece of code

Data : w_date type dats value '20080903', 
          w_date1(10),
Constants : C(1) value '.'.
w_date1 = w_date.

concatenate w_date+6(2) w_date+4(2) w_date+0(4) into w_date1 separated by C.

Write : / w_date1.

With Regards.

Alwasy Learner

naveen_inuganti2
Active Contributor
0 Kudos

Hi...

Check code in this FM...

HRGPBS_HESA_DATE_FORMAT

Thanks,

Naveen.I

Former Member
0 Kudos

Hello There.

Check out Eric's Correct answer for the same,

[SDN - Reference - Convert and Concatenate|]

Good Luck & Regards.

Harsh Dave

0 Kudos

hi Harsh,

thanks for the reference

regards

ec

0 Kudos

Your Welcome Sir.

Good Luck & Happy SCNing )))))

Föß
Active Participant

Hi,

if you just want to convert the date into the user format (user settings) you can use string expressions:

data date type d value '20190718'.
data(l_user_format) = |{ date date = USER }|. "RAW, ISO, USER, ENVIRONMENT
write l_user_format.

I know, the the question is very old, i just want to add new possibilities.

lg Johann

NicholasB
Product and Topic Expert
Product and Topic Expert
0 Kudos

Great! Exactly what I was looking for. As long as it suits the simplest and most beautiful way to achieve time conversion.

Just adding:
you can also avoid the literals at all, using the constants of class CL_ABAP_FORMAT:

    DATA(current_time) = sy-uzeit.
    WRITE:/ |Time: { current_time }|.
    WRITE:/ |Time (User format):        { current_time TIME = (cl_abap_format=>t_user) } |.
    WRITE:/ |Time (Environment format): { current_time TIME = (cl_abap_format=>t_environment) } |.
    WRITE:/ |Time (ISO format):         { current_time TIME = (cl_abap_format=>t_iso) } |.

Regards, Michal

mm_biswajit
Explorer
0 Kudos

Thank you for the simple solution.. its works fine