Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default how to get the random date between the start date and the end date?

hi,
how can get the random date if i give a start date(2007-01-01) to the end
date(2010-12-31)?futher,how can i achieve that the random date is not the
first date of month or the end date of month.
i.e start date 01-01-2007 end date 12-31-2007 i want get 02-01-2007 or
02-29-2008

can anybody give me a guide?

regards,
sebation


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default how to get the random date between the start date and the end date?

One approach ..

In A1: =RANDBETWEEN(--"1-Jan-2007",--"31-Dec-2010")
In B1:
=IF(AND(DAY(A1)<1,A1<DATE(YEAR(A1),MONTH(A1)+1,0 )),A1,A1+2)
B1 returns the random date screened off first/end day of month
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Sebation" wrote in message
...
hi,
how can get the random date if i give a start date(2007-01-01) to the end
date(2010-12-31)?futher,how can i achieve that the random date is not the
first date of month or the end date of month.
i.e start date 01-01-2007 end date 12-31-2007 i want get 02-01-2007 or
02-29-2008

can anybody give me a guide?

regards,
sebation



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 287
Default how to get the random date between the start date and the end

But that would skew the results, dates which are the 2nd or 3rd of the month
would be more likely to appear....and you could also generate dates outside
the range.

A little more complex but......

If you have your start date in A1 and end date in B1 then this formula will
give a random date from that range which isn't the 1st or last of any month


=SMALL(IF(DAY(ROW(INDIRECT(A1&":"&B1))+1)2,ROW(IN DIRECT(A1&":"&B1))),1+INT(RAND()*SUM(--(DAY(ROW(INDIRECT(A1&":"&B1))+1)2))))

confirmed with CTRL+SHIFT+ENTER

"Max" wrote:

One approach ..

In A1: =RANDBETWEEN(--"1-Jan-2007",--"31-Dec-2010")
In B1:
=IF(AND(DAY(A1)<1,A1<DATE(YEAR(A1),MONTH(A1)+1,0 )),A1,A1+2)
B1 returns the random date screened off first/end day of month
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Sebation" wrote in message
...
hi,
how can get the random date if i give a start date(2007-01-01) to the end
date(2010-12-31)?futher,how can i achieve that the random date is not the
first date of month or the end date of month.
i.e start date 01-01-2007 end date 12-31-2007 i want get 02-01-2007 or
02-29-2008

can anybody give me a guide?

regards,
sebation




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default how to get the random date between the start date and the end

Agreed.

OP: If you still want to play this tack, change B1 to:
=IF(AND(DAY(A1)<1,A1<DATE(YEAR(A1),MONTH(A1)+1,0 )),A1,"")
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"daddylonglegs" wrote in message
...
But that would skew the results, dates which are the 2nd or 3rd of the
month
would be more likely to appear....and you could also generate dates
outside
the range.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimum Date Greater Than Observation Start Date vito Excel Discussion (Misc queries) 2 August 14th 07 03:02 PM
count between start date and end date flow23 Excel Discussion (Misc queries) 5 May 10th 06 01:22 PM
Calculating Difference Between Start Date & Time And End Date & Ti Samwar Excel Discussion (Misc queries) 2 December 19th 05 12:42 PM
how do I do a Planned vs Actual start date & end date graph chivy76 Charts and Charting in Excel 0 September 26th 05 07:47 AM
how do I do a Planned vs Actual start date & end date graph chivy76 Charts and Charting in Excel 0 September 26th 05 07:47 AM


All times are GMT +1. The time now is 03:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"