The function to_char with sysdate is the most known way to retrieve current time in PL/SQL. The way:

select to_char(sysdate,'dd/MM/yyyy HH24:mi:ss') date from dual;

You get this:

14/08/2012 13:24:32

But, if need get milliseconds also, we should to use systimestamp and the characters ‘FFn‘, where ‘n’ will be number of digits. The milliseconds are the goal, then ’4′ is the number.

select to_char(systimestamp,'dd/MM/yyyy HH24:mi:ss.FF4') date from dual;

And results:

14/08/2012 13:24:33.2110

If you wants only milliseconds, jus keep ‘FF4’ and remove the others characters:

select to_char(systimestamp,'FF4') millis from dual;

Now you will get:


Good coding!