Monday, February 20, 2012

Problem with DATE FORMAT

Ciao, I've a view with a smalldate field (yyyy-mm-dd hh.mm.ss) MyDate
I put in my report a formula field, I want that MyDate is formatted as dd-mm-yyyy , i've tried a lot of solutions but when i launch the report from a vb application i get the error "20515: E' necessaria una data" (a data field is required)
But... the original field is a date!!! I don't understand what's the problem , could you help me?
I'm using Crystal Report 6.0 and Visual Basic 6.0Hi,
Can you post the code used in the Formula filed?

Madhivanan|||Try using the Convert in your formula field: CDate({FieldName})

Also, the end result of a formula field must be only 1 data type. Example: 'The Date is: ' & {DateField} is trying to concatenate a string and a date, Crystal doesn't like that. In order to avoid an error in this case, you would need to convert the Date to a string. If you did that, you would have no control over the Format of the date. In this case, you can set the Report's default Date Format to what you need (For CR 8.5, it located under Designer, Default Settings, click the Fields tab, then the Date button or Date/Time button).

How are you getting the Field to Crystal Reports? Make sure that it's passing the correct variable type. You may be getting the error because the date field is getting passed in as a string.|||I'm passing a smalldata field!
In my db is "2004-11-10 00:00:00.000", I want to view "10-11-2004" but i can't do it.
I don't understand how to format it right :-\|||I'm passing a smalldata field!
In my db is "2004-11-10 00:00:00.000", I want to view "10-11-2004" but i can't do it.
I don't understand how to format it right :-\
do u know VB.net...if yes do u mind helpin me :confused: please lemme know...
thanks!|||I know VB|||I have not looked at this in detail, but just check the data type - Crystal has both Date and DateTime fields, and the field you are using looks like a DateTime, not a date.

Dave|||Hi Surrender79, Try this. Create a formula filed having the following code
replace(totext(cdate({DateField})),"/","-")
and place it in the details section. Now you can see what you expected

Madhivanan|||:(

I've put my date (smalldate type) in a formula field as below:
ToText(Day ({MYDATE}),0)
+ "-" +
ToText(Month ({MYDATE}),0)
+ "-" +
ToText(Year ({MYDATE}),"####")

If I launch the report directly from Crystal Report preview I got the right date but when I call the report preview from VB automation, I got the error "A data field is required" ____
I've CR6, some of your suggest are not good in my reports.

Thanks anyway
Ciao :)|||Hi Surrender79, did you get any error in executing replace(totext(cdate({DateField})),"/","-")
Madhivanan|||Yes, It doesn't recognize the command "replace" and "cdate", infact in my crystal report I haven't those options :(|||In menu file "Opzioni Report" (Report Option) there's "Converti campo data/ora" (Convert date/time field).
Default setting is "Stringa" (String), so I've setted "Date".

But now... i've a other question: how could I edit the report settings from vb code?

No comments:

Post a Comment