Click here to Skip to main content
15,912,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use sql server 2008 when I put a datetime field into crystal reports it become string type. When I browse the field object it shows as a string type. So that I have issues when I pass a date in selection formula crystal report doesn't recognise as a date. Any reason for this is happening changing the data type from datetime to string in crystal reports?
Posted
Comments
Kenneth Haugland 28-Jul-12 1:48am    
What does it look like in the database and what does it look like in the crystal report. I would guess that it is custom to write datetime.ToString("MM/dd/yyyy") to a document...
Reji Ab 29-Jul-12 10:54am    
In the database the data type is datetime(yyyy/mm/dd hh:mm:ss)
It appears as same format in crystal report as well but the data type is string
Kenneth Haugland 29-Jul-12 11:06am    
I think this is a common problem, you need to format then string to Crystal Report, and if you want to save a new DateTime youll have to write a formmated DateTime.tostring("MM/dd/yyyy") as the database normally stores the datetime in american culture, and you are pobarbly running on british culture on your machine?
Reji Ab 29-Jul-12 10:48am    
if you put DateValue({myTable.strDate}) in the selection formula it
shows an error message "bad date format". My question is why the datetime type changed to string type in crystal report?

1 solution

You could try the DateValue function:

C#
DateValue({myTable.strDate})
 
Share this answer
 
Comments
Giorgi Tsagareishvili 12-Feb-20 14:05pm    
Tanks... Best solution!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900