Print Page | Close Window

Date format in crystal

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2521
Printed Date: 05 May 2024 at 4:49am


Topic: Date format in crystal
Posted By: gfredrick85
Subject: Date format in crystal
Date Posted: 05 Mar 2008 at 7:48am
I need to format the date either as mmddyyyy or yyyymmdd on a crystal report depending upon which radio button the user picks on the form.  I am using vb.net 2003 and the crystal reports that come with it.  The data is coming from SQL Server express. 
 
The code currently is:
 

crFormulaDBField1.Text = "{General." & "date" & "}"



-------------
Gunnard Fredrickson



Replies:
Posted By: Iago
Date Posted: 06 Mar 2008 at 2:32pm
Add the same field twice to you report.  Maybe on top of each other.
Format each,  Format Field and then customize.
Create a parameter of type Boolean.
Suppress both fields with the Parameter true for one and not true for the other.
in your reportdocument object use

myreport.SetParameterValue( name of param, value)



Posted By: gfredrick85
Date Posted: 07 Mar 2008 at 8:21am
How do you format a formulaFieldDefinition type field?
 
I think that may be a part of the problem.
 
Dim crformulaDBField8 As CrystalReports.Engine.FormulaFieldDefinition


-------------
Gunnard Fredrickson


Posted By: Iago
Date Posted: 07 Mar 2008 at 9:16am
A formula is going to have a type based on the result of the formula.
1=1  boolean
Date(somestring) date or datetime
 
What DB type is the date in SQL server Express Varchar or datetime?  If the type is a datetime, I think it would be much easier to use the field format options to control how the date is displayed, and that is inside of Crystal, not part of the VBCode.
 
I would send the report a parameter and not a formula. Place the field on the report twice.  Find the supress option and supress the field based on the value of the parameter.  Only one will show at a time, based on what your user checks in the VB.net application.
 
I guess you could use a formula that has a result of type Boolean.  Place that formula in the fx section next to the supress checkbox.
 


Posted By: gfredrick85
Date Posted: 07 Mar 2008 at 9:26am

The field in the db is actually a string.  Before you ask, yes I have tried to parse it out and rearrange the string depending upon which button on the form is pushed, but that does not work.  The field is:

"{Material." & "date" & "}"

and it goes into

crFormulaDBField1.Text = "{Material." & "date" & "}"

If I try to put "{Material." & "date" & "}" into a date like cDate I get an error message. 


-------------
Gunnard Fredrickson



Print Page | Close Window