Full Version: Any chance of getting random dates?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
WongMeister
Does anybody know of a way to generate a series of random dates in Access? I want to generate, through VBA a random date between today and two weeks ago.

Thanks.
fecdad
Public Function RandomDate() As Date
Dim rndNum As Integer
rndNum = Int((14 * Rnd) + 1)
RandomDate = Date - rndNum
End Function
Jerry Dennison
Actually, this is relatively easy using the DateAdd() and Rnd() functions.

DateAdd("y", -(Rnd([SeedField])*14 + 1), Date())
WongMeister
FedcDAD and Jerry,

Thanks!

This site is really getting to be my "Easy Button."
jmcwk
Rich,

See Attached
Jerry Dennison
You're welcome.

Good Luck!
Aquadevel
John,

I added your attachment to my 'MustSave' USB Drive. sad.gif

Aqua
jmcwk
Good Deal Aqua, Glad to help out problem I have in doing that is

1. Remembering I have it
2. Remembering the name
3. Remembering where I placed it

sad.gif
KristianDude
John,

QUOTE
I added your attachment to my 'MustSave' USB Drive.


....me too! Thanks!!!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.