DateTime Parameters in Crystal Reports - sql-server

I have written a stored procedure in SQLServer which accepts 2 parameters, both in dateTime format. The idea of the stored proc. is for the user to be able to search for specific cases between 2 different dates. The users are imputing the dates in mm/dd/yyyy format, and this returns data properly.
Now I need to turn this into a Crystal Report. I set up the report to use the Stored Procedure that I have written. When Crystal asks for the values of the 2 parameters, it will not accept them as mm/dd/yyyy format. It is trying to get me to put them in yyyy-mm-dd hr:mn:scds format.
Is there a way I can set up the report to accept the parameters as mm/dd/yyyy format?
Thanks in advance.

As far as I know you cannot control input format for the date parameters

In crystal report, you can right click the date variable and go to format, then choose the way you want the date to appear.
If the date is obtained correctly from the database, you can display it as you wish by changing the format.

Crystal Reports uses the datatype in the Stored Procedure. If you have a Date in your SProc Crystal will treat the value as a string and not display the calendar icon in the parameters popup. Solution is to change the Date to DateTime in your sProc and Crystal will display the calendar icon and format as yyyy-mm-dd automatically if your user clicks on the calendar icon. I know you probably want a DATE not DATETIME but use DATETIME I don't believe there is any other answer.

Related

Cannot format datetime in SQL Server Reporting Services report builder

None of the previous questions/answers on this topic are working for me; I'm a bit baffled. I've inherited my first SQL Server Reporting Services Report Builder report and was given the seemingly simple task of changing what was a date to a datetime. As you can see below I've successfully modified the underlying query and am getting back datetime types but I cannot FORMAT them as such on the report.
Results of my query:
My first instinct was that simply changing the type of the column (FirstProcessorCompletedDate) from date to datetime would make cue the report tool in on displaying date and time, but no luck. So...
Previous experience with report building tools told me to take the existing reference to the field and replace it with a format statement for that field, kind of like this:
Unfortunately, whatever I add here is getting interpreted as LITERALS by the report builder upon execution. AND YES, I DID TRY AN "=" IN FRONT OF THE FORMAT STATEMENT. This is just one variation of what I've tried.
Clearly this is not the old SSRS-type report building I am used to. I've Googled the heck out of this and searched Stack Overflow but no joy on the answer. I've looked a little at Calculated Fields but this seems like overkill. I don't want to calculate something, just format it.
What am I missing?
Don't modify the underlying query, that was your first mistake. date(time) data types don't have a format, they are binary values and your presentation layer changes that to a readable format. Once you change the "format" of a date(time) data type in SQL Server it is no longer a date(time) datatype, it's a varchar, and Format does not work on a varchar. How would you format the varchar value 'Hello, my name is Jane.' to the style MM/dd/yyyy hh:mm tt? You can't, and the same applies to a string representing a date.
Return the value of your column as a datetime to SSRS (don't convert it), and then change the Format Property of your cell in SSRS (hit F4 when you have the cell selected and you'll open up the cell's property pane) and change the format to MM/dd/yyyy hh:mm tt.

How to load specific date format into BigQuery

When loading a .csv file into BigQuery with dates with this format DD/MM/YY it doesn't work, if I specify the schema for the table and I select Date Format.
However, if I don't specify the schema and I choose Automatically detect it works and converts the date format into YYYY-MM-DD.
Is there any possibility of convert the date into the right format manually and specify the name for that field?
Thanks,
David
Unfortunatelly, there is no way to control date formatting from the load API. You can load data into STRING first, and then use Standard SQL's PARSE_DATE function to parse it using any custom format.

Importing specific date format to Excel from Microsoft SQL Server

I'm importing dates from a German SQL Server table into a German Excel file via the built-in Excel connection tool.
However the date format is just like in the SQL Server: 2012-08-08 but I want to display: 08.08.2012. When I double-click inside a cell it will recognize the German date formatting but of course I would like to have that format for the entire column without having to manually change it.
I also need to be able to use these dates for calculations.
Do I need to change something in SQL Server or how do I make this work?
Thank you.
The problem is that Excel does not recognise the SQL Server Date type. Cast the date to a Smalldatetime or Datetime, then import and format.
As long as it's recognized ad a date, you can set the formatting of the entire column to a custom one and set the value of the custom format to dd.mm.yyyy (or mm.dd.yyyy, depending on which you want).
Not a programming answer, but it will get you the display you want just by setting the custom format of the whole column.

How do I get a Date from SQL Server in Crystal Reports 11?

I have a stored procedure that selects from a table, two of the fields are DATE type in SQL Server, but when I select the stored procedure from Crystal Reports, the two date fields appear as Strings (in the YYYY-MM-DD format). I could write formulas to convert these to the MM/DD/YYYY output that is expected for this report, but is there not a way to get Crystal to recognize SQL Server dates?
yes, write formulas, YYYY-MMM-DD is the representation of a date.

Date format problem using SSIS for Excel into SQL Server

I am trying to import a column of dates from a spreadsheet in Excel 2003 into SQL Server 2005 using SSIS. I am in the UK so want dates formatted as dd/MM/yyyy.
Unfortunately, the column in the spreadsheet contains a mixture of dates stored as strings in dd/MM/yyyy (with Excel 'General' formatting) as well as dates using Excel 'Date' formatting dd/MM/yyyy (with locale 'English (United Kingdom)').
This is just the way it is and I can't expect the users to be able to sort this out themselves.
When looking at the spreadsheet, all of the dates visually appear correct i.e. dd/MM/yyyy.
I am trying to import the values into a varchar column in a holding table in the database. Then I run a stored procedure that copies these values into the proper table which contains a datetime column.
The problem is that the dates that are stored in the spreadsheet and use Date formatting get imported as MM/dd/yyyy into SQL Server and the dates stored as strings are getting imported as dd/MM/yyyy. I have IMEX=1 in the connection string.
Having dates using both formats in the same varchar column is obviously causing a problem when I try to put it into a datetime column, hence
SET DATEFORMAT MDY;
SET DATEFORMAT DMY;
are of no use.
Does anyone know why the SSIS package would import the seemingly correct dates in the Excel spreadsheet into SQL Server as MM/dd/yyyy anyway?
Is there anyway to force the SSIS package to import the dates as dd/MM/yyyy that will work with this combination of dates as strings and cells with date formatting applied?
Any other ideas?!
Many thanks,
Anthony
I think you have answered your own question. The import of date formatted cells are treated as dates and others as a string. Possibly you SQL server date setting is MM/dd/yyyy and hence the conversion.
Why don't you try adding a data conversion step in you SSIS package and convert everyting in the column into a single format - datetime or string. Then I am sure SQL server will handle all of them the same way.
Raj
What worked for me was to add IMEX=1 to the Excel connection string.
So it will look like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Folder1\Book1.xls;Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1";

Resources