In crystal report I am trying to convert datetime value to date to string - crystal-reports-2010

The following conversion is not working. I would like to see if anyone can be able to solve it.
Syntax:
ToText(Date({db.field}),"dd/MM/yyyy")
System is saying that the date id is required.

however ToText( Date({db.field}), "dd/MM/yyyy") is working fine....
the other simplest way is :
Crystal Report Design Window->Right click on date field->format Field->Customize the date format as you want to.

Related

How can I format a date in the Select property of an EntityDataSource

Fairly straight forward... I have an EntityDataSource where, in the Select property I'm pulling a variety of fields. One of which is a Date that I would like to have returned in the "MM/dd/yyyy" format. How can I accomplish this?
You could use the .ToString(Format Here)
DateTime time = EDS.Field;
Console.WriteLine(time.ToString(MM/dd/yyyy));
This solution works fine with me:
cast(it.[interview_start_date] as System.String)

Formatting a Crystal Report datetime field to date in Visual Studio

I have a report, and when it runs, it pulls a date. When the date is displayed on the report, it is displayed like:
11/20/2012 12:00:00AM
I'd like it to be displayed like:
11/20/2012
When trying to edit the formula in the Format Formula Editor, I get the following error:
This one Works perfect in almost any case:
ToText(Cdate({Command.Payment Date}),"dd/MMM/yyyy")
Assuming the field is a DateTime you need to use the ToText function for this, i.e.
ToText({tablename.fieldname}, "MM/dd/yyyy")
I ended up using this formula:
ToText(Cdate({tbl_R002.Date}))

How to format birt date report parameter?

By default if the input parameter to BIRT report is of type Date, it takes yyyy-MM-dd format.
Can we change to something else e.g. may be dd/MM/yyyy ?
You can change the input format for a date parameter. Click on "Change..." select Format as "Custom" and you can enter a valid format code as you like.
If you want to enter a default Date you still have to use the yyyy-MM-dd Format, this cannot be changed ( where I used new Date() in the Picture), but the output format will still be your entered format.
Another option is to use the format Date Time section in the Birt designer and choose the right locale and formatting for the date.
I have done it in Birt 3.7 and works fine
There can be many way to do that but the easy one is you can do this in SQL Query itself.
If you are using DB2 you may try
VARCHAR_FORMAT("Your Column Mapping Name",'DD-Mon-YYYY') AS dataSetName.
But this will change its Data type to String
Try if this make any seance.

Error tyring to add a parameter in MS Visual Studio

I am trying to create a report in MS Visual Studio and use the DateClosed as a parameter so that a user can select on 'DateClosed'. The error I am getting says:
Error Message: Conversion failed when converting date and/or time from character string.
The select satement is below is based on a view that I had to convert a string (DateClosed) to a datatime data type.
SELECT GrantNumber, GrantAmount, GrantDate, NatureOfGrant, SpecialInstructions, FullName, GMP, GrantType, Name, DateClosed
FROM V_WSF_GrantMakingPartnersGrants
ORDER BY DateClosed DESC
I am really confused because the 'ClosedDate' above is returning the value as a datetime data type. I can't cast it again, because it already sees it as a date. This is making no sense to me.
Can anyone tell me how to add the parameter into MS Visual Studio?
It's not clear where you are getting the data from - SQL Server or Oracle? So you want to pass the date? Ie, you enter 02/02/2012 and then click to generate report?
If you are passing to Oracle, you might have to use the sql function TO_DATE(xxxx). The same thing may apply to SQL Server but that is not an area I'm not familiar with. Therefore:
..order by DateClosed may have to read like this:
to_date(DateClosed, 'yyyy/mm/dd')
The 2nd parameter - must match the date format that you are sending in...
I hope this helps...
I think you should use the dateTime.formate to specify the format type on the dataBase..
like "YYYY-MM-dd". make sure the format is the same date format you are using on your DataBase string date.
I think this will solve your problem.

Datetime Format Setting In SSRS

We have a requirement where date time values would be passed to the report parameter which is of "String" date type (and not "DateTime"). The report parameter would be a queried one i.e. it would have a list of values in which the passed value should fall in.
The strange part is that if the date time value passed to this parameter is passed in this format mm/dd/yyyy hh:mm:ss AM/PM then only it succeeds otherwise a error is displayed (If month/date/hour/minute/second is having a single digit value then we need to pass single digit value to parameter as well).
Assuming that the report server picks this format from the "regional settings" in control panel, we tried modifying the date & time formats as yyyy-mm-dd & HH:mm:ss but the outcome was the same.
On researching more I found some suggestions specifying to change the language property in the rdl (I was not able to figure out how) but this would not be the solution I am looking for. I also found another topic here but it didn't provide the solution we are looking for.
I need to understand if this format is controlled at the report server level & is it configurable. It would be great if someone can provide some guidance.
Thanks.
Format(,"mm/dd/yyyy hh:mm:ss AM/PM ")
Then it doesn't matter what the regional settings are.

Resources