Results 1 to 5 of 5

Thread: Crystal Report Date Comparison

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    3

    Crystal Report Date Comparison

    I have a crystal report that has a field showing a date, but it comes in as a text field. I need to compare this field to the current date, so that the report will only display records where the date's field is within the current month. Is there a way to do reference modification, where I can start with the first character in the field, and take, say 2 characters? Or is there another way to do this?

    Any help and ideas will be greatly appreciated.

    Thanks in advance,
    Jessica

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

    Re: Crystal Report Date Comparison

    Add something like the following to the Record Selection Formula

    ToNumber(Mid ({Name of your date field},2,2)) = Month(CurrentDate)

    Change the 2,2 as required.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    3

    Smile Re: Crystal Report Date Comparison

    Thank you so much for replying. I couldn't get your suggestion to work, but after playing around with it for awhile, I got it to work.

    Code that worked:
    Month (CDate ({my date field})) = Month (CurrentDate)

    Again, thank you.

    Jessica

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

    Re: Crystal Report Date Comparison

    Note that your code may not work on all computers. CDate uses the computers Regional Setting when converting date strings to date fields.

    So, Month (CDate ({"01/02/2005"})) Could return 1 or 2, again depending on the regional setting.

    In what format do you store the date strings?

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    3

    Re: Crystal Report Date Comparison

    The format that is being used: mm/dd/yyyy.

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