1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

Unique Random Date in Range From Today

Discussion in 'SQL - Questions and Answers' started by disluker, Dec 23, 2008.

  1. disluker New Member

    Hi all

    I am trying to generate a unique random date in a given range, using today's date as the seed. The idea is to show up to 5 posts from a date in a blog's history, without repeating the date / posts. I know I could simply add a table for input date = output date, but that's appallingly clunky ... is there a relatively simple means to do this in SQL directly?

    Thanks a lot - Oliver
  2. my_s_e_l_f New Member

    Which database? What version?
  3. my_s_e_l_f New Member

    In Oracle, I would do something like this..random data +/- 50 days.

    SELECT to_date(round(dbms_random.value(to_char(sysdate - 50,'J'), to_char(sysdate + 50,'J'))),'J')
    FROM dual;

Share This Page