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 to timestamp conversion

Former Member
0 Likes
739

Hello there ,

I m coverting date to timestamp but not satisfied with the outcome .

input date is 20071213

and output is 20.071.213.000.000 .

i want output to be 20071213000000 or 2007121700:00:00.

plz provide help on this .

Thanks ,

Abhi .

Hello there ,

I m coverting date to timestamp but not satisfied with the outcome .

input date is 20071213

and output is 20.071.213.000.000 .

i want output to be 20071213000000 or 2007121700:00:00.

plz provide help on this .

Thanks ,

Abhi .

4 REPLIES 4
Read only

Kanagaraja_L
Active Contributor
0 Likes
670

Hi Abhi,

FMs:

BDL_GET_CENTRAL_TIMESTAMP

DATE_2D_TO_4D_CONVERSION

DATE_CONV_EXT_TO_INT

DATE_TIME_CONVERT

Another Way

The timestamp is in the format <date><time>. In your example (20072404161312), the date is 20072404 and time is 161312. You can transfer the timestamp into a string and then split the data. You can use the following ABAP code to separate the date from the time:

"w_ts is your timestamp, w_s is the temporary string

"w_date and w_time will be your final date and time.

data: w_ts type timestamp.

data: w_s type string.

data: w_date type sy-datum,

w_time type sy-uzeit.

w_ts = '20071111161312'.

w_s = w_ts.

w_date = w_s(8).

w_time = w_s+8(6).

Kanagaraja L

Read only

Former Member
0 Likes
670

Hi Abhishek,

Can u post ur code that does this part with the declaration so that i can analyze it better...

Regards

Naveen

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
670

Hi,

Use this.

data: str type string.

concatenate sy-datum sy-uzeit ',' '0000000' into str.

write:/ str.

or use this FM. 'FRE_CONVERT_DATE_TO_TIMESTMP'

Cheers,

Simha.

Read only

Former Member
0 Likes
670

Hi Kanagaraja L,

ur second idea helps me .

after concatenate assign it to timestamp varaible so that we donot get unwanted seperators .

Thanks ,