Create random Date/and Time [message #337027] |
Tue, 29 July 2008 12:58 |
biohazardbill
Messages: 57 Registered: March 2006
|
Member |
|
|
I need to generate a random date/time stamp for entry into a field. I will also need to have this within certain time constraints but could wrap that into loop if need be unless there is a simple way to do this.
Thanks
|
|
|
|
|
|
Re: Create random Date/and Time [message #337042 is a reply to message #337039] |
Tue, 29 July 2008 13:49 |
biohazardbill
Messages: 57 Registered: March 2006
|
Member |
|
|
Maybe you should read points 1 and 2 of the guidelines:
# Be polite!
# Never belittle anyone for asking beginner-level questions or for their English skills.
This is not a homework assignment, google nor yahoo searches have provided a good way to do this. My DBA is out of the office at the moment and I need to find a solution to meet a deadline. I have generated random numbers and random text strings in the past, however I need to now generate a random date and time stamp between 2 dates. It IS oracle related as the data will reside in oracle tables therefore must be populated using oracle syntax.
|
|
|
|
|
Re: Create random Date/and Time [message #337057 is a reply to message #337027] |
Tue, 29 July 2008 15:15 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
biohazardbill wrote on Tue, 29 July 2008 13:58 | I need to generate a random date/time stamp for entry into a field. I will also need to have this within certain time constraints but could wrap that into loop if need be unless there is a simple way to do this.
|
What would be the need for a random date and time value? This is an honest question as I cannot think of any myself.
|
|
|
Re: Create random Date/and Time [message #337059 is a reply to message #337057] |
Tue, 29 July 2008 15:25 |
biohazardbill
Messages: 57 Registered: March 2006
|
Member |
|
|
We have an application that distributes prizes. There is a quota for the amount of weekly prizes to become available, however when the new week begins we do not want all the prizes released at midnight the first day. Therefore we have a table that will release prizes through the week. We need to randomly generate dates and times for these to be released.
thanks to michel I got it to work...
select TO_DATE('07/30/08','mm/dd/yy') + dbms_random.value(0,86400*(to_date('3-Aug-2008', 'dd-mm-yyyy') - to_date('30-jul-2008', 'dd-mm-yyyy'))+1)/86400 from dual;
|
|
|
|
Re: Create random Date/and Time [message #337108 is a reply to message #337059] |
Tue, 29 July 2008 22:58 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
biohazardbill wrote on Tue, 29 July 2008 22:25 |
select TO_DATE('07/30/08','mm/dd/yy') + dbms_random.value(0,86400*(to_date('3-Aug-2008', 'dd-mm-yyyy') - to_date('30-jul-2008', 'dd-mm-yyyy'))+1)/86400 from dual;
|
Your format-masks do not resemble the format of your strings.
|
|
|