Select a random time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niz182
    New Member
    • Feb 2008
    • 5

    Select a random time

    Hey does anyone know how to select a random time of the day in oracle?

    im using

    [code=oracle]

    SELECT TO_DATE(TRUNC(D BMS_RANDOM.VALU E(2454467,24544 67+364)),'J')

    [/code]

    FROM DUAL;

    to select a random date from 2008, but need to randomly select a time from the day too.
    Last edited by amitpatel66; Feb 18 '08, 01:04 PM. Reason: code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to use this

    [code=oracle]
    select mod(to_char(sys date,'hh') + TRUNC(DBMS_RAND OM.VALUE(1,100) ),12)||':'||mod (to_char(sysdat e,'mi') + TRUNC(DBMS_RAND OM.VALUE(1,100) ),60)||':'||mod (to_char(sysdat e,'ss') + TRUNC(DBMS_RAND OM.VALUE(1,100) ),60) from dual
    [/code]

    Comment

    Working...