tag:blogger.com,1999:blog-5987791209900104222.post1363311040621529647..comments2023-12-27T05:16:09.968+02:00Comments on $cript Fanatic: Generating Random DatesShay Levyhttp://www.blogger.com/profile/14910279001063843963noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5987791209900104222.post-86321703480209742892018-02-22T21:01:25.982+02:002018-02-22T21:01:25.982+02:00You rock. Thank you! Staggered task triggers just ...You rock. Thank you! Staggered task triggers just got a whole lot easier.-Matthttps://www.blogger.com/profile/04887805398685968982noreply@blogger.comtag:blogger.com,1999:blog-5987791209900104222.post-48728993657733337382008-06-11T22:30:00.000+03:002008-06-11T22:30:00.000+03:00Hi Shay,Thanks for the reply! Applying what you fo...Hi Shay,<BR/><BR/>Thanks for the reply! Applying what you found, here is what we end up with:<BR/><BR/>[DateTime]$theMin = "1/1/2008" [DateTime]$theMax = [DateTime]::Now<BR/><BR/>$theRandomGen = new-object random<BR/>$theRandomTicks = [Convert]::ToInt64( ($theMax.ticks * 1.0 - $theMin.Ticks * 1.0 ) * $theRandomGen.NextDouble() + $theMin.Ticks * 1.0 )<BR/>new-object DateTime($theRandomTicks)<BR/><BR/>Thanks so much for the post. It was just what the Dr. ordered. :)<BR/><BR/>-<BR/>ScottAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5987791209900104222.post-37950281400950495122008-06-11T19:48:00.000+03:002008-06-11T19:48:00.000+03:00Hi ScottI found a piece of C# on the internet, I t...Hi Scott<BR/><BR/>I found a piece of C# on the internet, I twicked it:<BR/><BR/>[int64]$min = [int64]::maxValue<BR/>[int64]$max = [int64]::maxValue<BR/><BR/>$random = new-object random<BR/>$rnd64 = ($max*1.0 - $min*1.0)*$random.NextDouble() + $min*1.0<BR/>[Convert]::ToInt64($rnd64)<BR/> <BR/> <BR/>Can you check if it works for you?<BR/><BR/>-ShayShay Levyhttps://www.blogger.com/profile/14910279001063843963noreply@blogger.comtag:blogger.com,1999:blog-5987791209900104222.post-79814080374105192012008-06-11T18:53:00.000+03:002008-06-11T18:53:00.000+03:00This is actually very useful! I have a huge amount...This is actually very useful! I have a huge amount of files that for testing purposes would like to change the LastWriteTime to some random date between min/max. <BR/><BR/>You mention this is on ctp2, but I have some rendition of it installed with PowerShell v1. (trying to find it this is native or part of the Community Extensions). Anyway, I'm unable to get things to work as the min/max params to Get-Random cannot bind to my DateTime.Ticks because the number is too big (i.e. Int64 to Int32 conversion is not too happy).<BR/><BR/>I'm still trying to get this to work, but if you have any tips that would be cool!Anonymousnoreply@blogger.com