Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass ASP dates to CR in Selection formula??

Status
Not open for further replies.

keijen

Programmer
Jul 12, 2001
16
AU
Via an HTML form I am collecting two dates.
The vbscript (ASP) gets the dates thus:

' *********** Date Selection ********
XtalSdate = request.form("StartDate")
XtalEdate = request.form("EndDate")

I wish to send these dates to a report via -:
' *********** Send selection string **********
Session("oRpt").RecordSelectionFormula = strSelection

where strSelection is like
e.g. {Proj.Project_startdate} <= &quot; & XtalEdate & &quot; and &quot; & {Proj.Project_enddate} >= &quot; & XtalSdate

How do I present the 'string' dates to the report in a format/formula that CR recognises?
The rpt requires the dates as string values from ASP but chokes claiming &quot;a date or time is required here&quot; etc...,

I must send these dates as part of the selection formula, not as parameters.
I've previously successfully passed dates as parameters from asp, but how to do so in a selection string??

TIA.
 
If you're getting an error message &quot;a date or time is required here...&quot;, that means that your {Proj.Project_startdate} and {Proj.Project_endtdate} database fields are of date (datetime), not string, data type. To pass dates to Crystal record selection formula you can try something like this:

strSelection = &quot;{Proj.Project_startdate} <= #&quot; & XtalEdate & &quot;# and {Proj.Project_enddate} >= #&quot; & XtalSdate & &quot;#&quot;
Session(&quot;oRpt&quot;).RecordSelectionFormula = strSelection

 
Thanks, I'll certainly retry that way.

I ended up with this tangle to get a result...

' *********** Date Selection and format conversion ********
XtalSdate = Cdate(request.form(&quot;StartDate&quot;))
XtalEdate = Cdate(request.form(&quot;EndDate&quot;))
' ***
Syear = DatePart(&quot;yyyy&quot;,XtalSdate)
SMonth = DatePart(&quot;m&quot;,XtalSdate)
Sday = DatePart(&quot;d&quot;,XtalSdate)
XtalSdate = syear&&quot;,&quot;&Smonth&&quot;,&quot;&sday
' ***
eyear = DatePart(&quot;yyyy&quot;,Xtaledate)
eMonth = DatePart(&quot;m&quot;,Xtaledate)
eday = DatePart(&quot;d&quot;,Xtaledate)
XtalEdate = eyear&&quot;,&quot;&emonth&&quot;,&quot;&eday

' *********** primary selection *********
PriSelection = &quot;&quot;
PriSelection1 = &quot;{Initiatives.ProjectStatus} <> XtalStat1 &quot;
PriSelection2 = &quot;{Initiatives.Project_startdate} <= Date(&quot; & XtalEdate & &quot;) &quot;
PriSelection3 = &quot;(({Initiatives.ProjectStatus} = XtalStat2 AND {Initiatives.Project_enddate} >= Date(&quot; & XtalSdate & &quot;)) &quot;
PriSelection4 = &quot; OR {Initiatives.ProjectStatus} = XtalStat3)&quot;

PriSelection = PriSelection1 &&quot;AND &quot;&PriSelection2 & &quot;AND &quot; & PriSelection3 & PriSelection4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top