06-04-2007 7:24 PM
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!
06-04-2007 7:29 PM
06-04-2007 7:27 PM
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
06-04-2007 7:28 PM
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
06-04-2007 7:29 PM
06-05-2007 1:06 AM