Crystal Reports date from DB - crystal-reports

I have a problem to display a date in crystal reports. The field is from database, and it shows the time, too. I need to display only the date.
I observed that if I click on the Text Format from the date, in the Font tab at Sample it is showed with time. I think that is the problem, but I can't modify, I can't delete the time from the Sample box.
Do you have any idea how to resolve this?

The data-type of the column inside the database seems to be text/varchar instead of datetime.
The best would be to fix the data-type on the table inside the database.
If you don't have the option to change the datatype directly on the database, you can use following formula to convert it to DateTime inside the report.
If IsDate({Table.DateTimeColumn}) Then DateTime({Table.DateTimeColumn})
On the properties of the formula field there will be the option for the different formats then.

Related

Invalid Date error when entering record on Sharepoint list Datasheet view

I have a list on Sharepoint 2013. I've often use the Edit this list link to make bulk changes to the list in datasheet view with no problem. Last week I had a bunch of new records I needed to add so decided bulk copy and paste from Excel would be best. However, I get the error "Invalid date/time value. A date/time field contains invalid data. Please check the value and try again." The field is Date/Time with Date only display. The format I copied in was mm/dd/yyyy, which is how it's displayed (I realize there's a difference between formatting and display). In the past I've used this format to update dates with no problem. I've tried manually changing the date to other formats like yyyy/mm/dd (or with dashes -), and using the date picker and nothing works. I can add a new item using the form and no problem with the date. It's only happening in datasheet view.
I have 70+ records to add and would rather not have to open a new form for each one (I'm only adding info to 7 of the fields, and I first only pasted a couple records to make sure there were no issues). Are there any recent known issues about date fields in datasheet view? It's a pretty straightforward thing, no calculations are being used, I'm not trying to connect to another service, or use outlying dates (dates are all 2017) so I'm perplexed why this is an issue now and not before. Any thoughts on this would be appreciated.
Found the issue. I had another date field I was not using in that view that for some reason the default value had been set to Calculated field with a value of 1/1/1111. No idea how that got there but I removed that and set the default value to None and now the problem is gone. I found it by creating a new view with every date field in the list and systematically copying a date into each field (in bulk edit) and trying to save after each one until it saved. Then I checked the settings for the field that I was able to save with.

Reading Date from Database in the incorrect Format

I have a date fields in a SQL database which are stored in date and datetime2 format.
When executing the Read method on the SmartObject linked to this table, it tries to force the date into an American Format (MDY), and either display this date if it is valid, or fails to show anything (i.e. if the day is above 12)
However, when executing the List method, the data seems to display correctly, as it does when using the SmartObjectTester to execute the Read method on the object.
Is there a way to prevent this from happening, and to have the Date field be read in DMY format, and thus display correctly?
You can change the Data Type of the Field and in the Style Builder Change the "Date and Time" setting to use the format you need. Its always best to use User Settings. Style Builder for Date
This problem came from having the configuration of the Web.config set up to use a different culture to the one which the server K2 was installed on is using.
To solve this, ensure they are the same, and the Server should be able to read from the DB correctly, and thus display on the SmartForms without switching the dates around.
The relevant line to change in the Web.Config is
<add key="SmartObject.ExecutionCulture" value="en-US" />

Using Crystal Reports year to date

I am relatively new to using Crystal Reports. I am pulling the correct information from my database however I need to only pull the information from the beginning of the month to the current date, i.e. 09/01/2013 - 09/23/2013. Could anyone give me a snipit of code on how that would look.
Much appreciated.
The best way is you need to filter the data before it is populated on reports i.e. filtering the query itself. The other option is to create new parameter for the selected field and passing the value on runtime.
http://www.codeproject.com/Articles/205398/Crystal-Report-Filtering-Using-Selection-Parameter
In below figure you can add the records selection on the required field and add the condition similarly

Date format on input control

I'm using iReport 4.6.0 and JasperReports Server 4.5.0. I've created a report where I want to pass a date value to a MySQL database. I've created a parameter and used java.util.Date class. On the input control, I set it to a single value type, and the date data type. When running the report in iReport (using Preview), I'm prompted to select a date, and it generates the report using the specified date. After deploying the report to the JasperReports Server, when I'm prompted to enter a date, I get an empty report. I noticed the date format is different on the input control on the server (YYYY-MM-DD) than the one when previewing the report in iReport (MM/DD/YYYY). Is there any way to fix this?
I agree with mdahlman. The formatting of the input control shouldn't be a problem. It should be passing a valid date value to the report.
Make sure that the name of the input control (not the label) exactly matches the name of your parameter. And it is case sensitive. If they are not identical, this could be your problem.

Crystal Reports - Select Current YYMM

I'm trying to create a Crystal Report that reads data from an access table. I have a particular field in the access table called REPT_YYMM. This is basically a run data field, so each month when a program is run it populates the current year/month in the field before exporting to access, so there is a way to do month to month comparisons. For the report I'm working on I just want to display the data along with the current REPT_YYMM field when the data is refreshed on a monthly basis. Is there a way to do this in a formula. I'm not familiar enough with date type functions to know where to start.
Any guidance or suggestions are appreciated!
Your question isn't very clear but if i understood correct you just need to filter the data where field REPT_YYMM = YYMM.
Goto selection formulas, record and enter:
{table.REPT_YYMM} = cStr(currentdate,'yyMM');