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!

SelectionFormula - How to pass a date

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Im am trying to pass a date in the selectin formula as below;

Dim DteStart As String
Dim DteEnd As String
DteStart = Format(DTPStart.Value, "yyyy,mm,dd")
DteEnd = Format(DTPEnd.Value, "yyyy,mm,dd")

CrystalReport1.SelectionFormula = &quot;{transactions.transaction_date} >= Date(&quot; & DteStart & &quot;) AND {transactions.transaction_date} <= Date(&quot; & DteEnd & &quot;)&quot;

But I get an error 20515
Error in file c:\working\Reports\Statementtest.rpt:
Error in Formula <Record_Selection>.
'
'
The remaining text does not appear to be part of the formula

Can someone please help me with this ?
 
this is an awkward string format to work with:

DteStart = Format(DTPStart.Value, &quot;yyyy,mm,dd&quot;)
DteEnd = Format(DTPEnd.Value, &quot;yyyy,mm,dd&quot;)

try this instead

DteStart = Format(DTPStart.Value, &quot;yyyymmdd&quot;)
DteEnd = Format(DTPEnd.Value, &quot;yyyymmdd&quot;)

Now for the selection formula you want the date conversion to look like this in Crystal syntax anyway...Sorry I don't use Basic syntax much

{transactions.transaction_date} >=
date(tonumber(left(DteStart,4)),
tonumber(mid(DteStart,5,2)),
tonumber(right(DteStart,2))) and

{transactions.transaction_date} <=
date(tonumber(left(DteEnd,4)),
tonumber(mid(DteEnd,5,2)),
tonumber(right(DteEnd,2)))

You can translate that into your VB code....hope this helps
Jim




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top