Adding random hours to Date

Firasath

Board Regular
Joined
Feb 20, 2011
Messages
137
Office Version
  1. 365
Hi,

I'm using Vista OS and Excel 2007.

How can I add random hours to a date... I have a list of something around 7000 dates and I would like to add random time in between say 3 minutes to 8 hours, to all the dates... I have tried using RANDBETWEEN function, but I couldn't succeed. The date format I'm using is dd/mm/yyyy hh:mm AM/PM. Is there any good way to achieve it?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
In Excel a day is 1 so because RAND() generates a random value >= 0 and < 1 that will effectively add a random time, so if you have a date in A2 you could use this formula in B2

=A2+RAND()

If it must be betweem 3 minutes and 8 hours then, because there are 1440 minutes in a day this will give a random time between those but always on a whole minute

=A2+RANDBETWEEN(3,480)/1440
 
Upvote 0
Re: Adding random hours to bunch of Dates

try this

=A1+RANDBETWEEN(3,8*60)/24/60

Assuming your date value is in A1
 
Upvote 0
In Excel a day is 1 so because RAND() generates a random value >= 0 and < 1 that will effectively add a random time, so if you have a date in A2 you could use this formula in B2

=A2+RAND()

If it must be betweem 3 minutes and 8 hours then, because there are 1440 minutes in a day this will give a random time between those but always on a whole minute

=A2+RANDBETWEEN(3,480)/1440

Thanks alot, it helped me a lot. I got one more formula, which also worked for me. It is =A1+ROUND(RANDBETWEEN(0,800)/2*400,5). Both of them worked great for me. Thanks a lot.
 
Upvote 0
=A1+ROUND(RANDBETWEEN(0,800)/2*400,5)

I'm not really sure what that formula is supposed to do, the ROUND function is redundant so it does the equivalent of

=A1+RANDBETWEEN(0,800)*200

which will add multiples of 200 days to the date in A1
 
Upvote 0
Thanks alot, it helped me a lot. I got one more formula, which also worked for me. It is =A1+ROUND(RANDBETWEEN(0,800)/2*400,5). Both of them worked great for me. Thanks a lot.

It is not /2*400 it is /2400... I got it from one of the online Users and it worked for me. I got the following response from that User.

"The RANSBETWEEN and /2400 gives random numbers between 0 and 8/24 (decimal representing proportion of 1 24 hour day). The ROUND is because occassionally you get a small decimal above 8 hours and I wanted to avoid that".
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top