Formatting a Crystal Report datetime field to date in Visual Studio - visual-studio-2010

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}))

Related

Referencing a date from a cell in google sheets

I am trying to track stock prices with Googlefinance function in Sheets. I can pull the price for a date with =INDEX(GOOGLEFINANCE((B2),"price",date(2019,12,13)),2,2) which is fine but I want to input the date with Column A which has date data. So, (A1) instead of (2019,12,13)but for some reason I get errors.
This seems simple but I cannot get it to pull the date from my column. Ive tried removing DATE and just using the cell but this also doesnt work.
the formula that worked for me is
=index(GOOGLEFINANCE("YOUR_STOCK", "price",A1),2,2)
If, like you said, you already tried that and it did not work, you should link us a test sheet with your formula.
make sure A1 is really a date. you can check this with
=ISDATE(A1)
the output should be TRUE. your formula is correct:
=INDEX(GOOGLEFINANCE(B2; "price"; A1); 2; 2)

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

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.

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)

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.

Resources