Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Date format in crystal Post Reply Post New Topic
Author Message
gfredrick85
Newbie
Newbie
Avatar

Joined: 05 Mar 2008
Location: United States
Online Status: Offline
Posts: 3
Quote gfredrick85 Replybullet Topic: Date format in crystal
    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
IP IP Logged
Iago
Groupie
Groupie
Avatar

Joined: 01 Oct 2007
Location: United States
Online Status: Offline
Posts: 52
Quote Iago Replybullet 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)

IP IP Logged
gfredrick85
Newbie
Newbie
Avatar

Joined: 05 Mar 2008
Location: United States
Online Status: Offline
Posts: 3
Quote gfredrick85 Replybullet 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
IP IP Logged
Iago
Groupie
Groupie
Avatar

Joined: 01 Oct 2007
Location: United States
Online Status: Offline
Posts: 52
Quote Iago Replybullet 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.
 
IP IP Logged
gfredrick85
Newbie
Newbie
Avatar

Joined: 05 Mar 2008
Location: United States
Online Status: Offline
Posts: 3
Quote gfredrick85 Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.