‎2008 Mar 26 5:10 PM
Hello Abap Gurus!
Is there a FM existing whereby can convert all date-formats into miliseconds.
e.g
25.03.2008 -> milliseconds
03/25.2008 -> milliseconds
Regards
sas
‎2008 Mar 26 5:48 PM
‎2008 Mar 26 5:22 PM
I would say no because converting a date into milliseconds doesn't make any sense, logically. The only time it would make sense is if you wanted to know how many milliseconds are in a given day but then the answer would always be the same.
Davis
‎2008 Mar 26 5:30 PM
Davis
thank you but I dont care about whether it makes
a sense or not. Ijust need a suitable FM which fulfills these
creterias.
regards
sas
‎2008 Mar 26 5:34 PM
Davis is right, is like you are trying to convert meters to kilograms, it doesn't make any sense.
But, if you want to know the number of miliseconds in a day, that's possible, but every day has the same number of miliseconds, so still asking for a date doesn't make any sense because you are not going to evaluate it
‎2008 Mar 26 5:39 PM
You do care. If it isn't logical then there won't be a FM to do it. A simple calculation will give you the number of milliseconds in any given day.
Davis
‎2008 Mar 26 5:44 PM
Hi ,
I think this function module may be of some help which takes a date and a time and then gives the point of time from the mentioned date to the mentioned time in terms of seconds.
So again multiply with 60 to get the time in milliseconds.
CALL FUNCTION 'DATE_TIME_CONVERT'
EXPORTING
DATE = sy-datum
TIME = sy-uzeit
IMPORTING
POINT_IN_TIME = variable.
EXCEPTIONS
DATE_BEFORE_REL_DATE = 1
DATE_TO_BIG = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
In the above example, i took sy-datum and sy-uzeit i.e i want to get number of seconds from the mentioned date to the mentioned time.
variable is any data type ( preferably integer or packed because we need to multiply with 60 to get in terms of milliseconds).
Reward points if helpful.
Thanks and regards.
‎2008 Mar 26 5:46 PM
davis I am not kidding it is necessary for
date check. There is no other way to do it
Regards
sas
‎2008 Mar 26 5:57 PM
I'm not saying that it isn't necessary but I am saying that it doesn't make sense for the conversion, because it is a constant value, so there won't be an FM to do it. If you need the amount of milliseconds for a given date then do the calculation (it won't change from day to day) and create a constant with that value.
I get the feeling that you have other requirements and you just aren't articulating those requirements to us. If all you need is the number of milliseconds in a given day then do as I said; it will be the most efficient way to do it.
Davis
‎2008 Mar 26 5:48 PM
‎2008 Mar 26 5:54 PM
Your asking for millisecond for a date.. but milliseconds from what? Milliseconds is a function of time and to compute it you'll need a starting point.
‎2008 Mar 26 5:57 PM
Could you explain your requirement?
The way you are explaining doesn't make any sense and is impossible.
You could take the number of miliseconds from a given date starting from the beggining of the year 01.01.2008 to a ginven date and time.
But again, for example, every 03.01.xxxx would have the same number of miliseconds, so asking the year is only worth if you evaluate leap years or not.
You could also calculate the number of miliseconds from the epoch (or enoch?) of the gregorian calendar, 01.01.0001 to any given date (a really big number).
But the way you are putting it doesn't make too much sense
‎2008 Mar 26 6:29 PM
This is about the best you can do.. but you still need a FROM DATE.
DATA:
frmdt TYPE d,
rvsdt TYPE d,
mils(15) TYPE p,
rslt(15) TYPE p.
START-OF-SELECTION.
frmdt = '20080101'.
mils = 24 * 60 * 60 * 1000.
rslt = ( sy-datum - frmdt ) * mils.
WRITE:/ 'Mils in a day ', mils.
WRITE:/ 'Mils as of today ', rslt.
rslt = rslt / mils.
rvsdt = frmdt + rslt.
WRITE:/ 'Reversed calc should be today''s date', rvsdt MM/DD/YYYY.
and the output..
Mils in a day 86,400,000
Mils as of today 7,344,000,000
Reversed calc should be today's date 03/26/2008
‎2008 Mar 26 6:12 PM
hi use this...
parameters: p_test type sy-uzeit.
data: test type p decimals 4,
test1 type i .
test = ( p_test+4(2) ) * 10.
test1 = test.
write:/ test1.
regards,
venkat.
‎2008 Mar 26 6:17 PM