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

Displaying Date from a passed parameter in a certain format 1

Status
Not open for further replies.

Salthead

Programmer
Feb 25, 2003
7
US
I am writing an ASP.NET application that passes two dates to a Crystal Report. The dates are passed to create start and end dates for selection of records, and to also display this date range at the top of each page in MM/DD/CCYY order.

I developed this app on my laptop, and everything was working fine. I move it to the production server, and now the date is displaying in YY/MM/DD order, yet the selection is happening properly.

The date is entered into the two text boxes in MM/DD/CCYY order.

ASP.NET Code is here:
param.Value = txtStartDate.Text
values.Add(param)
crReportDocument.DataDefinition.ParameterFields(0).ApplyCurrentValues(values)
param.Value = txtEndDate.Text
values.Add(param)
crReportDocument.DataDefinition.ParameterFields(1).ApplyCurrentValues(values)

crReportDocument.Export()

The Crystal Reports Formula is called DateRange the code located here:

{?BegDte} & " - " & {?EndDte}

Any ideas why the date is being flipped around for display purposes, and what I can do to stop this from happening? I'm looking for both how to make this a system default as well as modifying the formula to ensure that the flipping doesn't take place.
 
Hi,

Try to format your crystal parameters by right clicking the parameter fields. Crystal always has default formats.

Thanks,
Hamida
 
Using your suggestion, I was able to create a work around by placing each date on the report separately with a label displaying the hyphen between the two dates. I made the first date right aligned, I made the hyphen center aligned, and I made the second date left aligned. I then right clicked on each to format the date display

The downside to this method is that each part of the date range must be manipulated every time you choose to change a font or other display characteristic. I would much rather be able to group the two dates and the hyphen in to a formula that can be treated as one entity. Unfortunately, right clicking on the date parameter in the formula does not give you the ability to format like right clicking on a report item does.

Hopefully, there is another way to accomplish this seemingly simple task.
 
It appears that you pass these dates as text, not dates, so I don't understand how the formatting is working as a date???

Anyway, another approach is to use a mask, as in:

totext(date({?begdte}),"MM/dd/yyyy") +" - "+ totext(date({?enddte}),"MM/dd/yyyy")

Switching the MM/dd/yyyy to however you'd like it formatted.

Also you can select multiple items for formatting by using the Ctrl->Left Click for multiple objects (if types allow), and format them as one.

-k kai@informeddatadecisions.com
 
Here's what finally worked for me:
totext(({?BegDte}),"MM/dd/yyyy") & " - " & totext(({?EndDte}), "MM/dd/yyyy")

Although I am passing strings from the text boxes to the date params, the date params in Crystal are typed as dates. Crystal must be performing the conversion upon accepting the params at fireup. Of course prior to allowing ASP.NET to fire up the crystal report, I am verifying that I have valid dates.

Thank you Hamida and synapsevampire for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top