how to generate random time in excel between a range ?
- State: Utah
- Country: United States
- Listed: 14 February 2024 21h18
- Expires: This ad has expired
Description
how to generate random time in excel between a range ?
How to Generate Random Time in Excel Between a Range? Two Battle-Tested Methods (and a Few Pro Tricks)
Ever needed to simulate shift schedules, create mock call-center logs, or just fill a sheet with plausible timestamps for testing? Excel has you covered—no add-ins, no VBA, just good old worksheet functions. Below are two reliable techniques I use almost daily, plus a handful of “I wish I’d known that sooner” tweaks.
————————————————
Method 1 – RANDBETWEEN + TEXT (the “pure-formula” route)
————————————————
1. Drop your boundaries into the sheet
• B1 → start time (e.g., 09:00:00)
• B2 → end time (e.g., 17:00:00)
2. In B3 calculate the span in Excel’s native time serial:
=B2-B1 (format as [h]:mm:ss to see 8:00:00)
3. In the cell that should show the random time (say A1):
=TEXT(RANDBETWEEN(0,$B$3*86400)/86400,”hh:mm:ss”)+$B$1
‑ RANDBETWEEN(0, seconds) creates an integer in the 0-to-span range
‑ dividing by 86 400 converts seconds back into Excel’s decimal-time value
‑ TEXT adds the cosmetic “hh:mm:ss” mask
‑ finally we add the start time back on
Hit F9 to recalc; each refresh gives you a new stamp between 09:00:00 and 17:00:00.
————————————————
Method 2 – RAND with scaling (the “one-liner”)
————————————————
Same boundary cells as above.
In A1:
=RAND()*($B$2-$B$1)+$B$1
• RAND() returns a decimal 0–0.999…
• Scale it by the time span, then offset by the start time.
• Format A1 as Custom → hh:mm:ss (or hh:mm if you don’t care about seconds).
Copy-down friendly: the relative/absolute references behave exactly like any other Excel formula.
————————————————
Pro Tips & Variations
————————————————
Need whole minutes only?
Wrap either formula in MROUND(formula, 1/1440) or simply format as [hh]:mm.
Need to “freeze” the timestamps?
Select the range → Copy → Paste Values. No more volatile recalcs.
Want to exclude weekends or night hours?
Use the same boundaries idea but plug them into a WORKDAY or MOD(…) check, or filter results afterward.
Need multiple non-overlapping stamps?
Generate a long list with Method 2, then Data → Remove Duplicates or use SORTBY with RANDARRAY in 365 for one-shot uniqueness.
————————————————
Grab-and-Go Template
————————————————
A1:Random Time
A2: =RAND()*($B$2-$B$1)+$B$1
Format A2↓ as hh:mm:ss, copy down as far as needed, and you’re done.
Use the links sprinkled throughout this post (ExcelJet, ExtendOffice, StackOverflow threads) for deeper dives—especially if you’re on Microsoft 365 and can abuse the new dynamic-array functions like RANDARRAY or LET to make the whole thing even shorter.
Now go forth and fill those sheets with perfectly believable, refreshable random times!
23 total views, 1 today