Pain Posted January 16, 2009 Share Posted January 16, 2009 I was shocked when I found out that AutoIt did not have any random date function. I couldn't find that anyone else did it before so I made one because I needed it in one of my project. #include <Date.au3> ConsoleWrite(RandomDate("2008/01/01 00:00:00")) Func RandomDate($Start) Local $Difference Local $rand If Not _DateIsValid($Start) Then MsgBox(0, "Error", "The specified date is invalid.") Return "" Else $Difference = _DateDiff('s', $Start, _NowCalc()) $rand = Random(0, $Difference, 1) Return _DateAdd('s', $rand, $Start) EndIf EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2009 Share Posted January 16, 2009 Good idea!! to be "random" #include <Date.au3> ConsoleWrite(RandomDate("2008/01/01 00:00:00") & @CRLF) ConsoleWrite(RandomDate("2008/04/01 00:00:00", "2008/05/01 00:00:00") & @CRLF) Func RandomDate($Start, $End = "") Local $Difference, $rand If $End = "" Then $End = _NowCalc() If Not _DateIsValid($Start) Or Not _DateIsValid($End) Then MsgBox(0, "Error", "The specified date is invalid.") Return "" Else $Difference = _DateDiff('s', $Start, $End) $rand = Random(0, $Difference, 1) Return _DateAdd('s', $rand, $Start) EndIf EndFunc ;==>RandomDate 8) Link to comment Share on other sites More sharing options...
trancexx Posted January 16, 2009 Share Posted January 16, 2009 Good idea!! to be "random" #include <Date.au3> ConsoleWrite(RandomDate("2008/01/01 00:00:00") & @CRLF) ConsoleWrite(RandomDate("2008/04/01 00:00:00", "2008/05/01 00:00:00") & @CRLF) Func RandomDate($Start, $End = "") Local $Difference, $rand If $End = "" Then $End = _NowCalc() If Not _DateIsValid($Start) Or Not _DateIsValid($End) Then MsgBox(0, "Error", "The specified date is invalid.") Return "" Else $Difference = _DateDiff('s', $Start, $End) $rand = Random(0, $Difference, 1) Return _DateAdd('s', $rand, $Start) EndIf EndFunc ;==>RandomDate 8)Nothing random comes out of there if I use it like this: #include <Date.au3> ConsoleWrite(RandomDate("2008/01/01 00:00:22", "2008/01/01 00:00:00") & @CRLF) Func RandomDate($Start, $End = "") Local $Difference, $rand If $End = "" Then $End = _NowCalc() If Not _DateIsValid($Start) Or Not _DateIsValid($End) Then MsgBox(0, "Error", "The specified date is invalid.") Return "" Else $Difference = _DateDiff('s', $Start, $End) $rand = Random(0, $Difference, 1) Return _DateAdd('s', $rand, $Start) EndIf EndFunc I'm doing something wrong, right? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2009 Developers Share Posted January 16, 2009 It says RandomDate() ... not RandomDateTime() SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
youknowwho4eva Posted January 16, 2009 Share Posted January 16, 2009 *Imagines a BlindDate() function* Giggity Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2009 Share Posted January 16, 2009 Now This is a Rabdom Date Function... ConsoleWrite(RandomDate() & @CRLF) ConsoleWrite(RandomDate("Male") & @CRLF) ConsoleWrite(RandomDate("Female") & @CRLF) Func RandomDate($iSex = "Male") $sList = "Cindy,Debbie,Laticia,Wilma,Sorry,Try Again!" If $iSex = "Female" Then $sList = "Brett,George,Ron,Jon,Sorry,Try Again!" $sSplit = StringSplit($sList, ",") Return $sSplit[(Random(1, $sSplit[0], 1))] EndFunc ;==>RandomDate 8) Link to comment Share on other sites More sharing options...
GEOSoft Posted January 16, 2009 Share Posted January 16, 2009 Now This is a Rabdom Date Function... ConsoleWrite(RandomDate() & @CRLF) ConsoleWrite(RandomDate("Male") & @CRLF) ConsoleWrite(RandomDate("Female") & @CRLF) Func RandomDate($iSex = "Male") $sList = "Cindy,Debbie,Laticia,Wilma,Sorry,Try Again!" If $iSex = "Female" Then $sList = "Brett,George,Ron,Jon,Sorry,Try Again!" $sSplit = StringSplit($sList, ",") Return $sSplit[(Random(1, $sSplit[0], 1))] EndFunc ;==>RandomDate 8) Hmmmmmmmmmm. Are you sure you have this part right? $sList = "Cindy,Debbie,Laticia,Wilma,Sorry,Try Again!" If $iSex = "Female" Then $sList = "Brett,George,Ron,Jon,Sorry,Try Again!" Not sure if I should raise an objection or not. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2009 Developers Share Posted January 16, 2009 George, you mean you wanted to be listed in the girly section? Sorry, let's all get back ontopic SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2009 Share Posted January 16, 2009 (edited) Hmmmmmmmmmm. Are you sure you have this part right? $sList = "Cindy,Debbie,Laticia,Wilma,Sorry,Try Again!" If $iSex = "Female" Then $sList = "Brett,George,Ron,Jon,Sorry,Try Again!" Not sure if I should raise an objection or not. That's Great, Your the winner, Someone who really read the code!!! 8) Edited January 16, 2009 by Valuater Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now