Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Parameters 1

Status
Not open for further replies.

edmac2

Technical User
May 11, 2000
24
US
I am trying to create a search based on 2 date parameters. Question #1 is there a way of inputting the date as a string instead of a date as it is very annoying to have to type DATE(2000,5,10) to ask for a date search. I seen one post where they said they put there date in as a string and then converted it to a date, how is this done? I am really new to this so as basic an answer as could be supplied would be appreciated. TIA
 
Have a look in the Crystal help for: <br>DTSToDate (DateTimeString)<br><br>That way you can pass it as a string &quot;01/31/2000&quot;, then have Crystal convert it to a date.<br><br><br><br> <p>Paul Wesson, Programmer/Analys<br><a href=mailto:paul@wessoft.com>paul@wessoft.com</a><br><a href= Wesson, Programmer/Analyst</a><br>
 
Here is the formula that I've used:<br><br>if {?Begin Date} = &quot;&quot; then PrintDate <br>Else<br>If NumericText(Left({?Begin Date},2)) = True<br>Then if NumericText(Right(Left({?Begin Date},5),2)) = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Then Date(ToNumber(Right ({?Begin Date},4)),ToNumber(Left({?Begin Date},2)),ToNumber(Right(Left({?Begin Date},5),2)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else Date(ToNumber(Right ({?Begin Date},4)),ToNumber(Left({?Begin Date},2)),ToNumber(Right(Left({?Begin Date},4),1)))<br>Else if NumericText(Right(Left({?Begin Date},5),2)) = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Then Date(ToNumber(Right ({?Begin Date},4)),ToNumber(Left({?Begin Date},1)),ToNumber(Right(Left({?Begin Date},4),2)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else&nbsp;&nbsp;Date(ToNumber(Right ({?Begin Date},4)),ToNumber(Left({?Begin Date},1)),ToNumber(Right(Left({?Begin Date},3),1)))<br><br>Note:&nbsp;&nbsp;It checks to see if a single digit is used for month and day, but requires 4 digits for year.&nbsp;&nbsp;It generally has worked well for me, I've copied it into several other reports as I hate retyping this thing too much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top