<%
Randomize
Sdate=int (Rnd * 3 + 2005)
Randomize
Sdate=sdate & amp; "-" & amp; Int (Rnd * 11 + 1)
Randomize
Sdate=sdate & amp; "-" & amp; Int (Rnd * 30 + 1)
If isDate (sdate) then
Response. Write sdate
End the if
% & gt;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Above problem resolved:
<%
The Function sdate '//Function name
Randomize
Sdate=int (Rnd * 3 + 2005) '//random year 2005-2008
Randomize
Sdate=sdate & amp; "-" & amp; Right (" 0 "& amp; Int (Rnd * 11 + 1), 2) 'in//
Randomize
Sdate=sdate & amp; "-" & amp; Right (" 0 "& amp; Int (Rnd * 30 + 1), 2) '//date
End the Function
% & gt;
Usage:
<% %=sdate & gt;
CodePudding user response:
This does not ensure that dateCodePudding user response:
Function getRndDate (byval s, byval e)
Randomize
GetRndDate=Cdate (DateAdd (" d ", int * e (RND), s))
End the Function
Response. Write getRndDate (" 2005-1-1 ", 365 * 4)
CodePudding user response: