Oracle generate random datetime

http://blog.csdn.net/itmyhome1990/article/details/45542055 1. Generate random

dates 01-01, 2015-12-31) * can be converted to 2015-01-01 + (0, 365), * where 2015-01-01 is 'specified date'; (0, 365) is 'specified range' */ 1. First determine the date integer of January 1, 2015: [sql] view plain copy select to_char(to_date('2015-01-01', 'yyyy-MM-dd'), 'J') from dual ; --The result given by the system is: 2457024  2. Generate a random date within the specified range [min_value, max_value]: [sql] view plain copy select to_date(2457024 + trunc(DBMS_RANDOM.VALUE(0, 365)), 'J ') from dual;  Second, generate random date + time [sql] view plain copy SELECT to_date(TRUNC(DBMS_RANDOM.VALUE( 



















       to_number(to_char(to_date('20150101','yyyymmdd'),'J')), 
       to_number(to_char(to_date('20150501','yyyymmdd')+1,'J')))),'J') + 
       DBMS_RANDOM.VALUE(1,3600)/3600 
       prize_time 
FROM dual; 

generate datetime within 2015-01-01 00:00:00 to 2015-05-01 23:59:59

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326238705&siteId=291194637