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

Date format

Former Member
0 Likes
741

Hi Experts,

I have a variable 'var_date1' in which I am passing the current date , and sending the same to a file.

data : begin of itab occurs 0,

var_date1 type sy-datum,

end of itab.

itab-var_date1 = sy-datum.

append itab.

clear itab.

itab-var_date1 = sy-datum - 1.

append itab.

clear itab.

My question is I want the date in internal table in the format MM/DD/YYYY.How to achieve this.What is the synax.

Regards,

Vishnu.

Edited by: Alvaro Tejada Galindo on Feb 6, 2008 4:03 PM

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
723
data : date(10),

date = sy-datum.

year = sy-datum(4).
month = sy-datum+4(2).
day = sy-datum+6(2).

concatenate month day year into lv_date seperated by '/'.
condense lv_date.
Read only

0 Likes
723

Hi Jay,

Is there any direct way to do this instead of hard coding.( Like edit mask or something?

Vishnu

Read only

0 Likes
723

Check this thread ..using edit mask

Read only

0 Likes
723

edit mask wont work for ur requirement..

check the documentation F1 of mask.... it might help you.. for future..

Read only

Former Member
0 Likes
723

Your date variables are all of type sy-datum which is 8 bytes. You cannot squeeze 10 bytes into an 8 byte field.

Rob

Read only

Former Member
0 Likes
723

Ur input is DD.MM.YYYY.format .Then check this..

Ex.

DATA: V_INPUT(10) VALUE '06.02.2008'.

DATA: V_OUTPUT(10).

CONCATENATE V_INPUT3(2) '/' V_INPUT(2) '/' V_INPUT6(4)

INTO V_OUTPUT.

WRITE: / V_OUTPUT.

Read only

Former Member
0 Likes
723

Hi Vishnu,

data : v_date(10).

write sy-datum to v_date dd/mm/yyyy.

add your required date format,

like dd/mm/yyyy or mm/dd/yyyy or any other.

Regards,

Ali

Read only

Former Member
0 Likes
723

Hi,

Use like:

DATA : BEGIN OF itab OCCURS 0,

var_date1 TYPE dats,

END OF itab.

itab-var_date1 = sy-datum.

APPEND itab.

CLEAR itab.

itab-var_date1 = sy-datum - 1.

APPEND itab.

CLEAR itab.

LOOP AT itab.

WRITE:/ itab-var_date16(2), ' / ' , itab-var_date14(2), ' / ' , itab-var_date1+0(4) .

ENDLOOP.

Regards,

Renjith Michael.