[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Crystal Report Convert String to Date

Posted on 2012-04-08
7
Medium Priority
?
1,607 Views
Last Modified: 2012-04-08
I declared a column in SQL table to varchar and the parameter in Crystal Report (asp) to Date.
Parameter1 is called DateFrom (Date)
Parameter 2 is called DateTo (Date)
I also created a formula in the Record:

ToText({Table.Date},"MM/dd/yyyy") >= {?DateFrom}
 and
ToText({Table.Date},"MM/dd/yyyy")<= {?DateTo}

I tried to convert the Table.Date to Date format and then use the parameter but it gives me an error like: "A string is needed"
The main reason I did this was that I did not want to use the DateTimeFormat in SQL and ONLY WANTED TO HAVE THE MM/DD/YYYY instead of THE Date and Time.

PLEASE HELP. This is driving me crazy.
FYI: I am using ASP.NET C# and this is my first asp, Crystal project so please be clear in your comments.
0
Comment
Question by:pauledwardian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37821064
You parameters and the values you are comparing them to must be th same data type.  You cannot have one as text and the other as date as in your post.

But since you are using varchar in your database aren't  the values already 'text'?  What datatype does Crystal see the date field as ?

If the dates are regarded by Crystal as text,  then unless they are already in a format that can be compared you will have to do two levels of conversion.  

I think we need to see some sample ' date ' values from the database.
0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 664 total points
ID: 37821103
convert specific sections and form date:-
CDate (
(ToNumber ({TextDateField} [1 to 4])),
(ToNumber ({TextDateField} [5 to 6])),
(ToNumber ({TextDateField} [7 to 8]))
)

refer here:
http://www.forumtopics.com/busobj/viewtopic.php?t=171929&sid=7c117f8d8872d20afe1f5a95a66bf8a0
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 1336 total points
ID: 37821290
Nice try buggy but the format of his field is mm/dd/yyyy

Try it this way

CDate (
(ToNumber ({TextDateField} [5 to 8])),
(ToNumber ({TextDateField} [3 to 4])),
(ToNumber ({TextDateField} [1 to 2]))
)

mlmcc
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:pauledwardian
ID: 37821777
I got this error: Please look at the attachment. I also changed my SQL dateformat to TEXT instead of Varchar:
This also includes a screenshot of the setting I used to format thew parameters:
Crystal Settings
0
 

Author Comment

by:pauledwardian
ID: 37821900
Never mind. I didnt verify the database after making the changes that was why it was giving me the error.
Now a differant question:
On the Report Preview in visual studio I can see the Refresh button on the report but when I compile the application and run the report it does not exit there.
How can I add that feature on the report OR how can I add a button in my C# page to Refresh the report?

Paul
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1336 total points
ID: 37821951
I have n't used that viewer but check the properties.  Each button usually has an ENABLE property

mlmcc
0
 

Author Closing Comment

by:pauledwardian
ID: 37822234
Thanks!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question