[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to filter a Crystal Report by dates ?

Posted on 2004-12-01
2
Medium Priority
?
351 Views
Last Modified: 2008-02-26
Hi guys, I need to make a filter with date fields, to let a user ask for a range of dates. I'm working with VB6, SQL7 and Crystal 8. I'm using the RecordSelectionFormula method like this: Report.RecordSelectionFormula = "{Table.Date} >= " & Chr(34) & msktxtDate.Text & Chr(34).

But that command gives an error like the field wouldn't be date-time. I tested different choices, by using CDate() function, or the SQL CAST command but still the same.

I hope you can help me !
0
Comment
Question by:LillianJohnsson
2 Comments
 
LVL 5

Accepted Solution

by:
RogueSolutions earned 450 total points
ID: 12717808

You could try ...

Report.RecordSelectionFormula = "{Table.Date} >= Date(" & msktxtDate.Text & ")"

However if msktxtDate.Text is ambiguous (i.e. date could be British or American) then you might be better to split it like ...

If msktxtDate.Text = "10/02/2004"

Report.RecordSelectionFormula = "{Table.Date} >= Date(" & MID(msktxtDate.Text,7,4) & "," & MID(msktxtDate.Text,4,2) & "," & MID(msktxtDate.Text,1,2) & ")"

Either way you are telling Crystal what you are giving it is a date.
0
 
LVL 1

Expert Comment

by:michaeldade
ID: 12717918
You may need to put a hash on either side of you date

Report.RecordSelectionFormula = "{Table.Date} >= " + "#" + msktxtDate.Text + "#"

also be careful with your date format dd/mm/yyyy or mm/dd/yyyy, this can be an issue, it could be either
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question