Results 1 to 3 of 3

Thread: [RESOLVED] Date selection

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    7

    Resolved [RESOLVED] Date selection

    Hi I have the following issue

    I have a program that counts the number of times a name appears in a Colum.
    The information is made visible with a Crystal report.

    But now i want to only count the names in the table where the Afmeld_datum colum, Which is in date format, is between two dates.

    I'm using Microsoft Visual Studio 2005
    Microsoft Visual Basic 2005
    Crystal Reports for Visual Studio 2005

    I use the following code:

    VB Code:
    1. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim mySelectFormula As String = "{SOverzicht.Afmeld_datum} BETWEEN '" & DateTimePicker1.Value.Date & "' AND '" & DateTimePicker2.Value.Date & "'"
    3.         CrystalReportViewer1.SelectionFormula = mySelectFormula
    4.         CrystalReportViewer1.ReportSource = Folder & "Test3.rpt"
    5.     End Sub

    The following code which i used before does work

    VB Code:
    1. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim mySelectFormula As String = "{SOverzicht.Gehaald} like 'J'"
    3.         CrystalReportViewer1.SelectionFormula = mySelectFormula
    4.         CrystalReportViewer1.ReportSource = "C:\Documents and Settings\Windows\Mijn documenten\Visual Studio 2005\Projects\Crystal test\Crystal test\Test3.rpt"
    5.     End Sub

    I get the following error:
    Last edited by eekhoorn12; Jan 19th, 2007 at 10:37 AM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Date selection

    You need to use Crystal Formula syntax not SQL. Something like

    VB Code:
    1. Dim mySelectFormula As String = "{SOverzicht.Afmeld_datum} In DateValue('" & DateTimePicker1.Value.Date.ToString("dd-mmm-yyyy") & "') To DateValue('" & DateTimePicker2.Value.Date.ToString("dd-mmm-yyyy") & "')"

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    7

    Re: Date selection

    Thanks.

    With some modification it worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width