Reputation: 31171
What is the best way to randomize the time part for a DATE column, using Oracle 10g?
For example, the date portion for the data was set as follows:
UPDATE table_name SET column_ts = SYSDATE - 120 + MOD(ROWNUM, 35)
I would like the time portion to have a different value for each row.
Upvotes: 1
Views: 221
Reputation: 30848
Choose a random number between 0 and 86400 (number of seconds in a day)
Add random / 86400 to your date.
SELECT TRUNC(SYSDATE)+DBMS_RANDOM.value(0, 86400-1)/86400 FROM DUAL
ADDITION:
UPDATE table_name
SET column_ts = SYSDATE - 120 + MOD(ROWNUM, 35) + DBMS_RANDOM.value(0, 86400-1)/86400;
Upvotes: 3