12-18-2006 9:46 PM
Hi friends,
I tried to use a simple format convertion, and i have problem, take a look of this code:
data: date_mask TYPE c LENGTH 8.
write sy-datum to date_mask DD/MM/YY.
write date_mask DD/MM/YY.
Output:
18.12.06
I debugg time:
sy-datum: 20061218
date_mask: 18.12.06
And i expect that the output were: "18/12/06".
Thanks,
Albio.-
12-19-2006 1:55 AM
Interesting. The DD/MM/YY or DD/MM/YYY changes the length of the output, but the actual separator is from the user master record
SAP F1 help: <b>For the character /, the separator that is defined in the user master record for date output is inserted</b>.
Another option would be to create your own conversion exit, but this is probably over-kill.
12-18-2006 10:02 PM
hi,
Use can use this code, it will print date according to required format:
data: date_mask TYPE c LENGTH 8.
data: v1(2) type c,
v2(2) type c,
v3(2) type c.
constants: slash type c value '/'.
start-of-selection.
v1 = sy-datum+6(2).
v2 = sy-datum+4(2).
v3 = sy-datum+2(2).
concatenate v1 slash v2 slash v3 into date_mask .
12-18-2006 10:08 PM
Hi Ashvender Singh,
Thanks for your reponse, i think your code it's going to work fine, but my question it's focused in order to know why the format option for the write statement doesn't work how it should do it.
I mean if i use "write sy-datum to var dd/mm/yy" the output should be in format "dd/mm/yy" and not "dd.mm.yy", that's the point.
Insted of that, thanks for your idea.
Albio.-
12-18-2006 10:29 PM
Hi,
The format is not working because of country settings.
The date setting is defined with dots (.). so you need to set the country first.
Just try using set country statement before the assigning the sy-datum to variable. It will convert according to the country date settings.
set country 'US'.
12-18-2006 10:31 PM
12-18-2006 10:03 PM
12-19-2006 1:55 AM
Interesting. The DD/MM/YY or DD/MM/YYY changes the length of the output, but the actual separator is from the user master record
SAP F1 help: <b>For the character /, the separator that is defined in the user master record for date output is inserted</b>.
Another option would be to create your own conversion exit, but this is probably over-kill.
12-19-2006 3:29 PM
Hi.
Well, thanks all for your help.
I Tried with set country 'US', but this country uses the format MM/DD/YY, and i need DD/MM/YY.
Finally i used this intruction:
REPLACE ALL OCCURRENCES OF '.' IN date_var WITH '/'.
And this resolve it.
Thanks,
Albio.-
12-25-2006 2:05 PM