cancel
Showing results for 
Search instead for 
Did you mean: 

How to change day in a date to starting day.

0 Kudos

Hello,

The date format is 20220912 needs to be changed to 01.09.2022.

Example - giving the input value 20220912 and the output has to be 01.09.2022, so here I need to change the day to first day.

So for, 20210823 to 01.08.2021.

How to append and concatenate?

How to write code for this? Please help me.

Thanks in advance.

jerryjanda
Community Manager
Community Manager
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members. Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community.

Examples of how you can improve a question:

* Outline what steps you took to find answers (and why they weren't helpful).

* Share screenshots of what you've seen/done.

* Make sure you've applied the appropriate tags.

If you don't apply the correct tags, the right experts won't see your question to answer it.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide, the more likely it is that members will be able to respond.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Kind regards,

--Jerry

Moderation Lead

FredericGirod
Active Contributor

20220912 is the way SAP record (most of the time) the date in the database.

This is the INPUT value (from the database point of view)

If you want the OUTPUT value, you need to convert it, but it depends of the date format you would like to use.

It is the userformat, just use WRITE my_date TO ...

If it is a non-standard format |{ my_date+6(2) }{ my_date+4(2) }{ my_date+0(4) }|

Accepted Solutions (0)

Answers (1)

Answers (1)

ThorstenHoefer
Active Contributor

Hi,

try this:

data: l_first_day like sy-datum.

l_first_day = |{ sy-datum(6) }01|.

write: l_first_day.