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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date string 1

Status
Not open for further replies.

mvas457

Programmer
Apr 4, 2001
33
US
I have a field called (usasdthp.effdte) that is defined as a string in the yyyymmdd format. I'm trying to generate a report that will only show the "current day" on the report. Any help/hints would be appreciated.

Thanks,
Mike
 
NumberToDate(tonumber({YourStringField})) will turn that into a real date.

Then in your record selection formula just put:

{@YourFormulaField} in CurrentDate Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
You'll need to download the numbertodate function.

You have other options, such as:

date(left({MyTable.MyStringDate},2)+"/"+mid({MyTable.MyStringDate},5,2)+"/"+mid({MyTable.MyStringDate},7,2))

Or you might create a real date field using a SQL Expression to be processed on the database, and use that SQL Expression in your record selection.

That will net the best performance.

-k kai@informeddatadecisions.com
 
I would change the current date to a string and use that as your parameter. Comparison to a formula means bringing all the records to the report computer then eliminating all those that don't match today - Crystal can't send it to the server - which is very high bandwidth. Using a SQL field is a lot better, but it requires a conversion on every record in your table which can end up being fairly CPU intensive if you have a large datasource.

The following is probably your best bet:

{YourStringField} = totext(currentdate, "yyyyMMdd")

Lisa
 
Lisa: Good point, especially if the (usasdthp.effdte) is an indexed column.

If it isn't, there shouldn't be much of a performance hit on a cast or convert on the string to a date, bit I'll bet your solution has at least equal performance, and probably better.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top