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: 

convert Date to Timestamp

Former Member
0 Kudos

Hi all,

can anyone kindly tell me how to convert system date (sy-datum) into long timestamp format (YYYYMMDDhhmmss,mmmuuun)?

if system date is today-- 06/04/2007

Timestamp formate 20070604000000,0000000

is it possible? thanks!

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Well you could do it manually.




data: str type string.

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

write:/ str.

Regards,

Rich Heilman

4 REPLIES 4

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please use this command to convert to date time stamp.

CONVERT TIME STAMP tst TIME ZONE tz INTO DATE d TIME t.

Also please check this FM FRE_CONVERT_DATE_TO_TIMESTMP.

Regards,

Ferry Lianto

former_member181962
Active Contributor
0 Kudos

YOu can make use of the ABAP statement:

GET TIME STAMP FIELD f.

Here's what the sap documentation for that field says:

"

GET TIME STAMP FIELD f.

Effect

Returns the timestamp in short or long form. The short form contains the current date and time; the long form also contains seven decimal places for fractions of a second, making the timestamp accurate to within 100 nanoseconds.

The target field f contains the global reference time UTC (Universal Time Coordination). This corresponds to Greenwich Mean Time (GMT).

For the short form of the timestamp, f must have the type P(8), and for the long form, the type P(11) DECIMALS 7. You can create data objects using the DATA ... TYPE ... statement with reference to the data elements TIMESTAMP and TIMESTAMPL respectively.

Note

You cannot use assignment with the time zone as you can, for example, with the ABAP types DATE or TIME. Instead, there are special statements that convert the timestamp into date and time components and output them. The time component is accurate to one second.

Fractions of a second are platform-dependent - with some products, the long form of the timestamp is accurate only to the millisecond.

Unlike the GET TIME statement, GET TIME-STAMP does not synchronize the ABAP clock with the system time of the database server.

Example

DATA:

s_tst TYPE timestamp,

l_tst TYPE timestampl,

tzone TYPE timezone.

GET TIME STAMP FIELD s_tst. "Short form

GET TIME STAMP FIELD l_tst. "Long form

tzone = 'UTC '. "Time zone

WRITE: / s_tst TIME ZONE tzone,

/ l_tst TIME ZONE tzone.

The short form might then contain the value 19980204163520, while the long form has the value 19980204163520,1234560.

"

Regards,

Ravi

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Well you could do it manually.




data: str type string.

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

write:/ str.

Regards,

Rich Heilman

thanks a lot! it resolved my problem