Application Development and Automation 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: 
Read only

need help on date

Former Member
0 Likes
1,153

1) In output I am getting the date in the format of MM/DD/YYYY. Instead of that I need in the format of YYYY/MM/DD? Can anybody help for code?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,129

hiii

use FM

data : date1(10) type c value '28.01.2008',
                   date2 type sy-datum.
 
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = date1
 IMPORTING
    DATE_INTERNAL                  = date2

or you can use following logic on date

s_date+0(4) = sy-datum+0(4) 
s_date+4(1) = '/'
s_date+5(2) = sy-datum+4(2)
s_date+7(1) ='/'
s_date+8(2) =sy-datum+6(2)

regards

twinkal

1) In output I am getting the date in the format of MM/DD/YYYY. Instead of that I need in the format of YYYY/MM/DD? Can anybody help for code?

9 REPLIES 9
Read only

Former Member
0 Likes
1,129

hi,

Use EDIT MASK

Read only

Former Member
0 Likes
1,130

hiii

use FM

data : date1(10) type c value '28.01.2008',
                   date2 type sy-datum.
 
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = date1
 IMPORTING
    DATE_INTERNAL                  = date2

or you can use following logic on date

s_date+0(4) = sy-datum+0(4) 
s_date+4(1) = '/'
s_date+5(2) = sy-datum+4(2)
s_date+7(1) ='/'
s_date+8(2) =sy-datum+6(2)

regards

twinkal

Read only

Former Member
Read only

Former Member
0 Likes
1,129

date 08/01/2008.

move date to date1 edit mask 01/08/2008.

Paras

Read only

Former Member
0 Likes
1,129

Hi,

Try using fm: FORMAT_DATE_4_OUTPUT

Raward if helpful,

Regards,

Sagar.

Read only

Former Member
0 Likes
1,129

output I am getting the date in the format of MM/DD/YYYY. Instead of that I need in the format of YYYY/MM/DD?

hi

if u r displaying the field using write st

then go with

write: var4(4) '/' var2(2) '/' var+0(2).

or else store the concatenated value of

var4(4) '/' var2(2) '/' var+0(2).

into another variable and display the second variable

reward points if helpful

Read only

Former Member
0 Likes
1,129

Hi,

If you are referring to standard output to change to required format, following steps will help.

Follow menu path System --> User Profile --> Defaults tab --> Change Date Format to YYYY/MM/DD.

Note : Above settings will be user specific.

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
1,129

Hi Kanneganti.

I would like to suggest,

CONVERT_DATE_FORMAT - Convert date from yyyymmdd to ddmmyyyy format

I would like to suggest a reference,

[SDN Code Gallery - Standard Reference for FUNCTION MODULE FOR CONVERTING DATE INTO THE GIVEN FORMAT|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/function%2bmodule%2bfor%2bconverting%2bdate%2binto%2bthe%2bgiven%2bformat]

Hope that's usefull.

Good Luck & Regards.

Harsh Dave

Read only

Former Member
0 Likes
1,129

hi,

this code will help you.

if u want to convert the format from dd.mm.yyyy to yyyy.mm.dd.

first split it .

Declare three variables like date,month, year to capture the values of date. month & year respectively.

to do this use offset.

and then concatenate it according to ur requirement.

i am sending here the code for that.

regards

Nilabichi.

REPORT ZDATE_CONVERSION.

data : var type ersda ,

var_1(20) TYPE c,

year(5) TYPE c,

month(5) TYPE c,

date(5) TYPE c.

var = '01082008'.

year = var+4(4).

month = var+2(2).

date = var+0(2).

CONCATENATE year'/' month '/' date INTO var_1 SEPARATED BY space.

WRITE :var_1.