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: 

How do I declare a field like a date?

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I am using read_text in a loop and the long text that I will get has a value of like

06/05/1981-06/09/1983. Now I used split command to split the 2 dates at '-'. Suppose I

created 2 fields in a structure to hold those 2 dates, what will be its type? is datum?

Because when I run my report, the date shows like this:

06//05/19 or

06/05/198

Thanks again guys and take care!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

type? is datum

no <b>declare it like char.</b>

data: date1<b>(10).</b>

now it work ine...

9 REPLIES 9

Former Member
0 Kudos

type? is datum

no <b>declare it like char.</b>

data: date1<b>(10).</b>

now it work ine...

Former Member
0 Kudos

Take it as string

data : l_date type string.

Former Member
0 Kudos

If you want to move the dates as is (with the slashes separating the numbers), you will have to declare a char10 field. datum is a char 8 field and that is why the last 2 digits get truncated.

DATA: date1(10) type char.

Hope this helps.

Sudha

Former Member
0 Kudos

datum is 8 Char field , try to use 10 char field.

like date(10) type c.

regards

prabhu

Simha_
Employee
Employee
0 Kudos

Hi,

data : date like sy-datum.

data : date1(10).

CONCATENATE date6(2) '.' date4(2) '.' date+0(4) INTO date1.

hope it helps,

cheers,

Simha.

Former Member
0 Kudos

Hi,

In the internal table declare it as a character,

DATA: lv_date1(10),

lv_date2(10).

Regs,

Venkat Ramanan

Former Member
0 Kudos

Hi Viray,

Take two character fields of lengths 10 each and convert these two character fields into date by considering type SYDATUM.

DATA:

V_CHAR1(10),

V_CAHR2(10),

V_DATE1 TYPE SYDATUM,

V_DATE2 TYPE SYDATUM.

V_DATE = '06/05/1981-06/09/1983'.

SPILT V_DATE AT '-' INTO V_CHAR1 V_CHAR2.

CONCATENATE V_CHAR16(4) V_CHAR13(2) V_CHAR1+0(2) INTO V_DATE1.

CONCATENATE V_CHAR26(4) V_CHAR23(2) V_CHAR2+0(2) INTO V_DATE2.

Thanks,

Vinay

Former Member
0 Kudos

Hi,

Date fields are type d with the fixed length 8 and the internal representation YYYYMMDD (year, month, and day).

If u declare it as type datum or d, it will take only 8 chars in it. so declare a char variable of lenght 10.

DATA : ldate1(10) type c.

Rgds,

Prakash

0 Kudos

Thanks guys!

You all have been very helpful!