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: 

issue with date format save in custom database table

Former Member
0 Kudos

Hi ,

I want to save date in MM/DD/YYYY in custom database table field . its displaying as dd.mm.yyyy format. I know we can use char 10 and do necessary concatenation but i want any other good method for this.

rg

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Go to System->User Profile -> Own Data -> Defaults -> Date Format (choose 2. MM/DD/YYYY).

Your default setting is the reason you are seeing the date in that way.

Raju.

11 REPLIES 11

Sandra_Rossi
Active Contributor

You should tell your client that it's a very bad idea from the modeling point of view, to not using the predefined date type (because it's then impossible to sort efficiently). Of course, they probably have a good reason to do that.

Former Member
0 Kudos

Go to System->User Profile -> Own Data -> Defaults -> Date Format (choose 2. MM/DD/YYYY).

Your default setting is the reason you are seeing the date in that way.

Raju.

0 Kudos

Hi,

I know we can maintain that in SU3, I am looking for any other method.

rg

"Date Format (choose 2. MM/DD/YYYY)"

It's a "other good method". No?

pokrakam
Active Contributor

It's all in the documentation. Please look at the formatting options of string templates or the WRITE statement.

former_member188080
Active Contributor
0 Kudos

see if you can use any of customer exit for eg below one

split the date like below(I am giving just a psudo code) in the customer exit

example: MM/DD/YYYY - YYYYMMDD

A1 = SOURCE_FIELDS-calday+0(4) . ** YYYY

A2 = SOURCE_FIELDS-calday+0(2). **MM

A3= SOURCE_FIELDS-calday+2(2). ** DD

Concatenate A1 A2 A3 into your date field.

0 Kudos

Use a structure rather that substrings, or use the substring() function. The structure method is self documenting this in my view is a better way of coding it.

Types: Begin Of My_Date,
             Month Type My_Month,
             Fill1 Type c,
             Day   Type My_Day,
             Fill2 type c,
             Year  Type My_Year,
       End Of My_Date,
       Begin Of Sap_Date,
             Year  Type My_Year,
             Month Type My_Month,
             Day   Type My_Day,
       End Of Sap_Date.
Data: l_Date     Type my_Date,
      l_Sap_Date type sap_Date.
l_Date = 'MM/DD/YYYY'.
Move-Corresponding l_Date to l_Sap_Date.

And then just move l_Sap_Date to a real date field. To go the other way, populate the SAP date and move to the l_Date, populating the fill fields.

Rich

ChrisSolomon
Active Contributor

Same as Sandra Rossi......and wondering why you aren't just making this a "date" type field.....then use the "external-to-interal" conversion function to take "whatever" format the end user is using (based on their user profile setting as mentioned elsewhere in this thread) and then puts into the "internal" format SAP uses to actually store dates. Why try to complicate it? Unless as Sandra said, there are other "good" reasons for doing this.

raghug
Active Contributor
0 Kudos

Another voice to this being a bad idea... maybe if you share the specific reason for trying to store a formatted date, we can give you better (or just other) ways of addressing your primary issue.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

She says it's displaying ...

Maybe the storage format is even OK but not recognized as such. Simply not distinguishing internal format and external formats.

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Ramya,

Can you try EDIT MASK option in WRITE statement for DD/MM/YYYY format as shown below.

data: l_date TYPE char10.

write sy-datum to l_date USING EDIT MASK '__/__/_____'.
write sy-datum to l_date USING EDIT MASK '__.__._____'.
write sy-datum to l_date USING EDIT MASK '__-__-_____'.

Regards

Rajkumar Narasimman