开发者

Format date like M/D/Y

I got a date of the type SYDATUM and wondering how to format it in a format like m/d/y.

I've found some snippets on the web, but they were not really helpful.

-thanks yor your 开发者_如何学编程help.


You should be more specific - what exactly do you want to do with the date (use type D internally, it's shorter and does the same thing).

  • Do you want to WRITE it to a list screen? Use the formatting options described in the documentation and online help:

    WRITE l_my_date MM/DD/YYYY.

  • Do you want to convert it to a text variable? Very similar:

    WRITE l_my_date TO l_my_text MM/DD/YYYY.

  • To set the date format in a SAPscript form, see the SET DATE MASK command.

  • To print the formatted date in a SmartForm, use the WRITE command and a temporary variable (yes, ugly, I know...)

  • Most controls (ALV Grid for example) should take care of the format automatically.

However - be careful when hard-coding the format into your application. Usually you don't have to do this because the system automatically uses the format specified in the user master data. This ensures that every user will see the date formatted according to their locale settings.


Normally it's better to export the date into the plant level country specific date format:

if w_country is initial.
  select single LAND1
    from T001W
    into w_country
   where WERKS eq w_the_plant.
endif.

SET COUNTRY w_country.

write w_the_date to w_export.

for example 03/04/2002 could be different date in different country.


You can try the keyword TRANSLATE. Alternatively suggest you could have a look at this link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜