+ Reply to Thread
Results 1 to 3 of 3

How to Generate a random time and date together

  1. #1
    Registered User
    Join Date
    02-27-2018
    Location
    Michigan, United States
    MS-Off Ver
    2016 Excel
    Posts
    19

    How to Generate a random time and date together

    How do you generate a random set of date/time only in the month May of 2013 and between times 8am and 9:59am.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to Generate a random time and date together

    I would put enter 1 May 2013 into a cell (after entering it, you could format as general to see the serial number for the date, if you wanted). Then enter 31 May 2013 into a second cell. Then =RANDBETWEEN(cell with 1 May, cell with 31 May) to generate the date serial number.

    Time is just a fraction (real number) of a day. The RAND() help file has a formula for generating a random real number between two numbers a and b. Using the formula given in the RAND() function help file (https://support.office.com/en-us/art...0-021ea9f5be73 ), you could enter 08:00:00 into a cell (again, format as general to see the actual fraction of a day, if you want) and 09:59:00 into a second cell, then enter the formula from the RAND() help file =RAND()*(cell with 9:59-cell with 8)+cell with 8. Once you have both parts, simply add them together to get the final random date/time serial number.

    If you don't like the cell references, once you have the serial numbers for the dates and times, you can enter those numbers as constants into those formulas.

    edit to add: if you are unfamiliar with Excel's date/time serial number system, I recommend something like this to bring yourself up to speed: http://www.cpearson.com/Excel/datetime.htm
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Spammer
    Join Date
    01-08-2015
    Location
    Cali, Colombia
    MS-Off Ver
    365
    Posts
    302

    Re: How to Generate a random time and date together

    Hi, to both!

    Try this formula:
    =RANDBETWEEN(--"2013-05-01",--"2013-05-31")+RAND()*("9:59"-"8:00")+"8:00"

    Blessings!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Random, but not quite random... I'd like to generate combos with set rules...
    By LottoLinks in forum Excel Formulas & Functions
    Replies: 38
    Last Post: 01-05-2019, 08:46 PM
  2. Replies: 10
    Last Post: 07-03-2015, 04:29 PM
  3. Generate a time interval with a random number for the seconds
    By n_ant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-01-2015, 09:37 PM
  4. (How to) generate a different random number each time?
    By soldout2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2013, 04:30 AM
  5. [SOLVED] Generate random 6-16-byte random hexadecimal number
    By jsamuelshn in forum Excel General
    Replies: 6
    Last Post: 07-20-2012, 10:38 AM
  6. Generate Random Time
    By mthem2003 in forum Excel General
    Replies: 5
    Last Post: 07-20-2009, 11:07 AM
  7. generate a random number and use if function to generate new data
    By Dogdoc1142 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2006, 10:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1