2008 Apr 10 2:19 PM
Hi,
Does SAP have a function module which can read in a date/timestamp and output that time in milliseconds (a long integer starting from 1st January 1970)?
Many thanks in advance,
Peter
2008 Apr 10 2:35 PM
try:
PARAMETERS:d2 TYPE sy-datum DEFAULT sy-datum,
d1 TYPE sy-datum default '19700101'.
data sec_day TYPE i . "ms per day
DATA : d TYPE i.
DATA result TYPE f.
DATA rp(16) type p decimals 0.
AT SELECTION-SCREEN ON d2.
IF d2 LE d1.
MESSAGE e001(00) WITH 'date must be greater than 1970/01/01'.
ENDIF.
START-OF-SELECTION.
sec_day = 24 * 60 * 60 * 1000.
d = d2 - d1.
rp = result = d * sec_day.
WRITE: / d2, d1, d, / result, rp.
hope that helps
Andreas
Edited by: Andreas Mann on Apr 10, 2008 3:37 PM
2008 Apr 10 2:24 PM
HHMMSSZZZ (H=hours, M=minutes, S=seconds, Z=milliseconds).
Use FM CRMBW_GET_TIME
You can use GET TIME keyword and there you can specify the format that you want.
DATA: BEGIN OF wa,
...
time_stamp TYPE timestampl,
...
END OF wa.
...
GET TIME STAMP FIELD wa-time_stamp.
INSERT dbtab FROM wa.
Regards,
Santosh
2008 Apr 10 2:35 PM
try:
PARAMETERS:d2 TYPE sy-datum DEFAULT sy-datum,
d1 TYPE sy-datum default '19700101'.
data sec_day TYPE i . "ms per day
DATA : d TYPE i.
DATA result TYPE f.
DATA rp(16) type p decimals 0.
AT SELECTION-SCREEN ON d2.
IF d2 LE d1.
MESSAGE e001(00) WITH 'date must be greater than 1970/01/01'.
ENDIF.
START-OF-SELECTION.
sec_day = 24 * 60 * 60 * 1000.
d = d2 - d1.
rp = result = d * sec_day.
WRITE: / d2, d1, d, / result, rp.
hope that helps
Andreas
Edited by: Andreas Mann on Apr 10, 2008 3:37 PM
2008 Apr 11 11:43 AM
Many thanks Andreas!
Just one thing - I make the number of milliseconds in a day 86400000
(10006060*24) - one less zero
Peter