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

report date range

Status
Not open for further replies.

sheridan101

Programmer
Dec 31, 2003
29
US
I wrote a report viewer in C# and am using Crystal Reports.NET. What is the best way to pass a report start datetime and a report end datetime from a custom C# prompt/requestor to corresponding start/end date parameters in the report? I have tried several different things and keep running into brick walls. I am probably close but in each case am missing that last little piece of info that will make it work. The information I have on this is sketchy at best. Any help would be appreciated!!

Ideally, I would like to pass the dates into a date range datetimepicker in the report. One wall I ran into is I can't find any way to set the CR parameter's MinDate/MaxDate values from the viewer program.

I am using custom prompts because the defaults built-in to the datetimepicker in the report parameter is crap. None of the "defaults" fit because I need a custom built date for the prompt default values that can change every time the report is run. Specifically, I need to set the date part to today, but the time to a fixed time. The CR defaults has no provision for this, and there appears to be no way to change a ?parameter within the report... these parameter fields appear to be read only from within the crystal reports code itself.
 
CR does allow for what you're asking for.

There was a similar request the other day that I fielded, was that you?

Setting todays date but for 8 AM:

cdatetime(year(currentdate),month(currentdate),day(currentdate),8,0,0)

If you want to change the default prompt in the parameter, then we can't do that.

Anyway, this is what you want:


-k
 
No. However, I read a couple of threads on this but none seemed to be exactly what I needed. The ones I found were wanting to send a single date value, while I need to pass two date values.
 
This example shows passing a range to a date parm (though it's for a subreport).

If you're passing 1 value to both a start and end date parameter that should be straightforward.

-k
 
It is almost there. One problem I am having is that the DateTime control keeps changing the format. I have it doing a custom format on the display, but the only apparent way to assign a value to the "StartValue" and "EndValue" parameters of the ParameterRangeValue object is to convert the date of the source object to a string using "ToString()". However, ToString() does not pay attention to the object output format so it outputs the datetime in a completely undesired format which causes an exception when I try to apply the new values to the crystal reports object. I can't seem to find a way to get the date to a usable format and ToString() does not have any parameters on the datetime objects so I don't know if there is any to get it to change it's output format.

For example, the format being used on the display of the prompts in my custom requestor is "MMMMM dd, yyyy hh:mm:ss tt". That is also the format I have set in the Crystal Reports parameter. However, ToString() converts it to "MM/dd/yyyy hh:mm:ss". So, when I try to assign the date from the requestor, it causes an exception as the report runs. The way .NET handles datetime is CRAP! I wish the idiots over at MS would THINK for a change. I guess I am just going to have to change the parameter format in CR... GEEEZZZEEE!!
 
OOPS. Sorry. There does not appear to be any way to change the date format of the CR parameter. This is exactly what I mean when I said that I keep running up against massive brick walls. NOTHING SEEMS TO BE EASY OR WELL DOCUMENTED!!
 
Can't you convert the format of "MMMMM dd, yyyy hh:mm:ss tt" to "MM/dd/yyyy hh:mm:ss". before passing it?

-k
 
I have tried to see if the field on the dialog has a format conversion. It doesn't. I have checked to see if there is a custom format field associated with ToText() on the object. There isn't.

What I ended up doing is assigning the value to a newly constructed datetime object (since it appears datetime is readonly once constructed), in the program after returning from the dialog call, and then using it's ToString(), which DOES have a format argument (geeze!) to convert. Why there and NOT the datetimepicker object?!?!?!?!?!?

My peeve is forcing you to NEEDLESSLY waste process time, constructing an object for the sole purpose of converting a datetime parameter from one format to another!!! It's no wonder that programs are getting bigger and slower forcing you to upgrade to faster machines. Doing this kind of NEEDLESS crap [or other more strongly worded explitive] bogs down programs!! It's almost as if Microsoft has a special deal with hardware manufacturers. MS takes extra steps to force the code to get bigger and slower just to force you to keep upgrading to faster machines just to run the programs at an acceptable speed. Not to mention the extra memory needed to load a program footprint into memory!! It gives them a reason to keep making Windows bigger and slower and more "feature rich".

I have found, in many ways, that forcing you to use the "canned" objects in .NET is more limiting than VC++. At least there you could invent a better mouse trap. In C#/.NET, you're stuck with what you have "in the can"... that is if you still want to keep the code "managed". I think it will be a while before C# becomes a language of choice for serious commercial game makers because of crap like this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top