Sunday, March 25, 2012

Date Problem

Hi...

i wannna thank about this hard work ur doing in this forum.

actually, i'm using vb6 and crystal report 4.6

the problem is that i want to generate a report searching about 2 specified dates from the user.
I tried these codes

1) CR.SelectionFormula = "{SoldItems.Date} in ('" & Date1.Value & "') to ('" & Date2.Value & "')"

2) CR.SelectionFormula = "{SoldItems.Date} Between DateValue('" & Date1.Value & "') And DateValue('" & Date2.Value & "')"
but they don't work

For example, i want to get a report about the sales from
03/15/2004 to 05/10/2004

can u help me with that and how that could be coded in vb6 plz
?where r the expert users?|||We've all been on holidays over Christmas, or at the Betty Ford Clinic, or undergoing electroconvulsive shock therapy............it's the price we pay for involvement with Crystal reports...:-)
Me, I've been thanking the Great Universal One that I wasn't in Phuket or somewhere in that region. Tragic.
On to your comparatively small problem on the pathway to Crystal Enlightenment.

Firstly, why not use parameters for the report, like pStartDate, pEndDate and allow the user to supply these when report is run? Maybe you want to automate it and that is the reason. If so, fair enough.

Secondly, the following has your dates encased in single quotes, which means they are going to be evaluated as strings by the SQL parser. Is that correct?

1) CR.SelectionFormula = "{SoldItems.Date} in ('" & Date1.Value & "') to ('" & Date2.Value & "')"

Try this:
CR.SelectionFormula = "{SoldItems.Date} >= " & Date1.Value & " AND {SoldItems.Date} <= " & Date2.Value

This would evaluate to the following string being passed;
"{SoldItems.Date} >= 2004/01/06 AND {SoldItems.Date} <= 2005/01/06"
which means the parser should see the dates as dates, not strings.

dave|||thx so much springsoft

i'm gonna try what u wrote and i hope it's gonna work

thank u again and sorry about being late

No comments:

Post a Comment