Print Page | Close Window

string manipulation

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=250
Printed Date: 02 May 2025 at 11:57pm


Topic: string manipulation
Posted By: blkhills
Subject: string manipulation
Date Posted: 27 Feb 2007 at 3:28pm
I'm a newbie, first report I ever worked on.  I have a text field that has dates entered into it (9/30/2007).  This field needs to be in my where criteria.  I would like to have the user enter a date range and then check this field and return records within this date range.  How do you convert a text value to a date value?
 
Thanks



Replies:
Posted By: BrianBischof
Date Posted: 27 Feb 2007 at 7:52pm
To convert a string to a Crystal Report date, use the CDate(field) function. You can find more functions in my free online chapters.
http://www.crystalreportsbook.com/Chapter06_XI.asp - http://www.crystalreportsbook.com/Chapter06_XI.asp


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: blkhills
Date Posted: 28 Feb 2007 at 9:00am
I appreciate your efforts to help.  I have seen the same information in the help screens of Crystal but since I've never had a Crystal class, never even opened the program until yesterday, I'm at a loss as how to apply the CDate function.  In Crystal "Select  Expert" I have added a tab for the field id_6 which is my text field, used the 'formula' choice and tried CDate{Workstat.ID_6} <="07/01/2007".  Am I approaching this correctly?
 
I should add the fact that the values in the field are already in a date format.  I have also tried the following
If ISDate({Workstat.ID_6}) Then
Formula CDate({WORKSTAT.ID_6}) <= 07/01/2007
EndIf
 
or If ISDate({Workstat.ID_6}) Then
Formula CDate({WORKSTAT.ID_6}) <= "07/01/2007"
EndIf


Posted By: BrianBischof
Date Posted: 28 Feb 2007 at 9:24am
To keep things simple, I would first create an independent formula just to convert the string to a date. It's only code would be:
CDate({WORKSTAT.ID_6})

Then I would use the select expert and pick this formula as the new tab and say that it is less than 07/01/2007. That way you're not trying to do too much at one time. Plus, you should read my free online chapters. They will teach you how to go about creating formulas.





-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window