‎2005 Aug 30 4:57 PM
Hi,
I have the date 20050703 , in the format YYYYMMDD,
and I need the most efficient way of converting it into the format DD.MM.YYYY , so the above date would be
03.07.2005
What is the best way of doing this?
thanks!!
‎2005 Aug 30 5:07 PM
‎2005 Aug 30 5:06 PM
Where do you want to do it?
If in an abap list:
WRITE SY-DATUM DD/MM/YYYY.
‎2005 Aug 30 5:08 PM
Hi,
I want to put it into a variable: as in the code below
bdcdtab-dynpro = '0000'.
bdcdtab-dynbegin = ' '.
bdcdtab-fnam = 'BKPF-BUDAT'.
bdcdtab-fval = '12.07.2005'. " ybsid-budat CPosting Date in the
and I have the date in ybsid-budat
‎2005 Aug 30 5:13 PM
I think the better and easier way is to write data in format DDMMYY, and so:
WRITE MY_DATE DDMMYY TO bdcdtab-fval.
This format is ok for B.I.
‎2005 Aug 30 5:22 PM
Max,
Shouldn't this be just -
write my_date (or ybsid-budat) to bdcdtab-fval.
Sims,
This is the correct way to format date, this will format date according to the user's date format(as per user profile). You shouldn't hardcode the date format, when you can easily write more generic logic.
Cheers,
Sanjeev
‎2005 Aug 30 5:37 PM
I didn't write
write my_date (or ybsid-budat) to bdcdtab-fval.
but
write my_date (or ybsid-budat) DDMMYY to bdcdtab-fval.
So if my_date is 20050830, bdcdtab-fval is 300805.
This format is always ok for whichever B.I. of FI, infact, for example, if you use B.I. standard (RFBIBL00) all date fields are long 8 char, so you can't write date in the format that Sims want to use (30.08.2005).
Moreover this format is not depend on user's date format, so I can always be sure that my B.I. is ok for all users.
I'm agree with you, the statament WRITE has many options to format a date and it's better to use them than to process it by concatenate
Message was edited by: max bianchi
‎2005 Aug 30 8:10 PM
Please close the post once resolved so that others wont try to answer it anymore.
Thanks,
Srinivas
‎2005 Aug 31 4:25 AM
Hi,
Date formatting
The following code demonstrates a number
of ways to format a date value:
* Using the WRITE statement
***************************
data: gd_date(10).
"field to store output date
* Converts date from 20020901 to 01.09.2002
write sy-datum to gd_date dd/mm/yyyy.
* Converts date from 20020901 to 01.09.02
write sy-datum to gd_date dd/mm/yy.
* Using data manipulation techniques
************************************
data: gd_date(8).
"field to store output date
* Converts date from 20010901 to 01092001
gd_date(2) = sy-datum+6(2).
gd_date+2(2) = sy-datum+4(2).
gd_date+4(4) = sy-datum(4).
* Using Function modules
************************
data: gd_date(8).
"field to store output date
* Converts date from 20010901 to 01SEP2001
gd_date = sy-datum.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
input = gd_date
IMPORTING
OUTPUT = gd_date.Refer this link
http://www.sapdevelopment.co.uk/tips/date/date_format.htm
Kindly reward points and close the thread.
‎2005 Aug 30 5:07 PM
‎2005 Aug 30 5:14 PM
‎2005 Aug 30 5:18 PM
‎2005 Aug 30 5:09 PM
WRITE ybsid-budat USING EDIT MASK '__.__.____' to bdctab-fval.
‎2005 Aug 31 4:31 AM
Hi Sims,
If you don't close the thread, people are still thinking that it is not solved for you and trying to help you. Since you mentioned, Rich's solution solved your problem, please close the thread so that others wont try to answer this.
Thanks,
Srinivas