Tuesday, April 24, 2012

Oracle - Random Timestamp Generation

In case you want to generate a random timestamp for a given date you can use the following query

select to_timestamp(sysdate) + (dbms_random.value(0,86400)/86400))
from dual;


Where I have used sysdate to represent today's date, 86400 represents the number of seconds in a given day.