Cast to date
hi to all,
I need to change the variable type from varchar to data; I prefer to do this in the .RPD, in the 'Business Model and Mapping' layer.
I've created a new logical column as:
CAST ( SUBSTRING(Commerciale.FACT_USCITA.Data_Pagamento_Cont FROM 1 FOR 4) || '-' || SUBSTRING(Commerciale.FACT_USCITA.Data_Pagamento_Cont FROM 5 FOR 2) || '-' || SUBSTRING(Commerciale.FACT_USCITA.Data_Pagamento_Cont FROM 7 FOR 2) AS DATE )
but it's wrong..
could somebody help me?
thanks
Is the datatype do read string or number?
What is the error code?
Regards,
Stefan
Similar Messages
-
Hi All ,
I want to know if casting of data types is possible in ABAP. I mean if I have declared a datatype as
data : x type char5.
and Now I want to make x as char10.
Is there any method to achieve this?
Thanks and regards
SujeetHi Sujeet
If your requirement suits, you can use dynamic programming which is a nice feature of ABAP.
You can use field-symbols (think them of as aliases for fields) or generic variables.
For more information I recommend the e-class <a href="https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/eclasses/teched04/ABAP351.htm">"Advanced and Generic Programming in ABAP"</a>.
As a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts which help you solving your problem. You can reward points by clicking the yellow star icon at header of each post. You can assign:
- one 10 points (solved)
- two 6 points (very helpful answer)
- many 2 points (helpful answer)
Kind regards...
*--Serdar -
Casting a date type into sql.date
Hi there ...I trying to cast this sentences...please help me out...thanks
sentencia.setInt(4,Integer.parseInt(request.getParameter("FECHA_INICIO")));
sentencia.setInt(5,Integer.parseInt(request.getParameter("FECHA_FIN")));
both of them are date and the values wii go into a database on oracle...im working wuth jsp too..If you need to insert a date, why are you creating an int from a string and using setInt()?
Create your Date object from the request parameters and use setDate() instead. -
Rounding Differences between TSQL Cast and Data Conversion component
This is using SSIS 2012. We are using an Ole Db Connection manager using the Microsoft.ACE.OLEDB.12.0 provider.
I have an Access database (accdb). It has several columns that are coming into SSIS as real data types. One column has a value of 68.8335558900872.
In the past we used the Data Conversion to convert from real to numeric 18, 6. The result was 68.833555. Rather than rounding on the last decimal place, it is returning the floor at six decimal places.
We have converted the process to load the data into a real data type column and then use a view to cast the value to a Decimal 18,6 (CAST (Col1 as Decimal(18,6))). We then load the data into a decimal 18,6 column. The result is 68.833556, which
is the rounded version of the real value.
Personally I prefer the rounded version rather than the truncated version.
I am trying to explain to explain to the QA people why the revised process is producing different results and thus I want to know if these are known behaviors for TSQL Cast and the Data Conversion component.
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.comI think such a post is more suitable for an MS Connect bugs section as I see it a defect. And it seems no floor, but simply cutting off. Try in .Net when you convert, does it work the same? Data Conversion is a wrapper around the .net
Arthur My Blog -
Convert/Cast string data type from file to DT_GUID into table
Hi to all
is there anyone who help me please?!?
I'm not able to resolve the following problem.
I have a .csv file with a string field A and its values are GUID.
I must export this .csv file into SQL Server Table which have a uniqueidentifier (GUID) field B.
I must map string field A to GUID field B of table.
But I get an error like this: "Error at Data Flow Task [Derived Column [xxx]]: Error code 0x800401F3 occurred attempting to convert from data type DT_WSTR to data type DT_GUID.".
I read other posts like this in this forum and i also tried the solution suggested in those posts.
The proposed solution had suggested of insert in the expression field of "Derived Column" Transformation this expression (DT_GUID) ("{" + [YourGuid] + "}") in place of (DT_GUID) [YourGuid].
But i get always the same error.
is there anyone who help me please to resolve this issue?!?The derived column expression should work if the yourGuid column contains a real guid.
Does the source looks something like: 25892e17-80f6-415f-9c65-7395632f0223
And are all rows filled with a correct value or are there also empty strings or null values?
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter -
I have a few hidden input fields that contain integers and I am going to insert these values into a sql server db into fields of type int. I tried using the CAST() function in my query, but it keeps throwing an error saying:
[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'AS'.
Is there anything wrong with my query?
<cfquery datasource="db1">
INSERT INTO testSetup (id1, id2, id3, position, testStartDate)
VALUES(
<cfqueryparam cfsqltype="cf_sql_varchar" value="form.id1">,
CAST(#form.id2# AS INTEGER),
CAST(#form.id3# AS INTEGER),
1,
<cfqueryparam cfsqltype="cf_sql_varchar" value="form.startDate">
</cfquery>Try using CFQUERYPARAM instead of CAST.
<cfqueryparam cfsqltype="cf_sql_integer" value="#form.id2#">
You should also put pound signs around the form variables in all of your CFQUERYPARAM tags. This tells CF to treat these as variables instead of literal strings.
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.id1#">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.startDate#">
If testStartDate is a datetime column in your table you should change the cfsqltype to CF_SQL_TIMESTAMP if you are using MS SQL Server. -
Casting a date == type C
Hi,
Can anyone tel me the syntax to convert a date (Or number) to string.
Thank you in advance.
MustaphaHi,
Just create a var and use WRITE <var_date> TO <var_char>. -
I have an SQL Server function to take a JDEdwards numeric date and convert it to an SQL Date field.
CREATE FUNCTION [dbo].[date_ccyyddd_to_mmddyyyy]
@JulianDate as Numeric(18,0)
RETURNS Date
AS
BEGIN
Declare @ResultDate as Date
Set @ResultDate = DATEADD(YEAR, @JulianDate / 1000 + 1899, Cast('01/01/0001' as Date))
Set @ResultDate = DATEADD(Day, @JulianDate % 1000 -1, @ResultDate)
RETURN @ResultDate
END
In many query based reports we have used the function. It works quite nicely for all but one user. For this one user Crystal is casting the date result as a string, it will then display as a yyyy-mm-dd format instead of his default mm/dd/yyyy short date format. It would generally be ok but since it is typed as a string if the user exports the results to excel it is not recognizing the column as a date either. The strange piece of the equation is that if the user saves the report to the enterprise server and I open it, go to edit the SQL command, do nothing, close the edit box, it gives me the unmapped fields wizard where I can fix the report. Thus when I open or generate a new report with this function it "knows" the result is a date but with a specific user it sees the result as a string.
Has anyone had a similar situation or can lead me in the correct direction to fix this? Unfortunately, this user is our power user, he writes more reports than anyone else. It appeared as a problem when we upgraded from Crystal Enterprise 2008 to 2013.
Current work around for user is to use a crystal CDate() function on the report side but I would like to get the correct solution.
Any assistance appreciated,To add to Dell's suggestion:
If OLE DB then use:
MS SQL 2005 - OLE DB Provider
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11
If ODBC then use:
MS SQL 2005 - SQL Native
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter -
Does CAST ( date as timestamp) causes performance issues
Hi
does casting from DATE to TIMESTAMP in a query or in a view causes the slow down of performance??
Please guide...
Thanks
RimpiEverything you do affect performance. How significantly is a question answered by testing not by asking questions on an OTN forum.
Create a loop doing it 10,000 times and find out.
And, in the future, always include your version number. -
Hi all,
Any idea why the timestamp is lost after casting a date into a varchar (FYI : datatype is datetime in the rpd)
if I have a date like ;
date = 5/2/2011 9:18:26 AM
CAST (date as varcchar(100)) gives 5-2-2011
Is there anyway to avoid this lost of precision
Best regards
AdilHi adil,
To eliminate timestamp,which i faced long back was a horrifying task.So i used trunc function this way
You can do this way by going to physcial layer of RPD and go to the table the date column is coming from
1) go to properties of the table
2) go to general tab and change the table type to SQL
3) Write the SQL by selecting required columns from that table including this date column i.e.
select x,y,trunc(date_column) from table_name
This way the timestamp will be gone.
CAST (date as varcchar(100)) gives 5-2-2011 I suppose as your converting it to varchar,it is assuming it as a string and omitting precision but changing to default date format(dd-mon-yy).
UPDATED POST
Ok got you wrong,so you want the he precision while converting it to char so you need to use evaluate with char and give the format and precision the way you require.
hope helps you.
Cheers,
KK
Edited by: Kranthi.K on Jun 1, 2011 10:16 PM -
Cast 3 Concatenated Fields as Date
Hi,
I have the following requirement. On the contact page there is a drop down field named Starting month of months (Jan to Dec). On the report i need to show Starting Date column, which is a concatenated field of 01 as date, Value in the Starting month field and current year.
For Ex: If user select Feb , on the report in Starting Date column it should display 01-Feb-2011. This can be achieved using combination of concat functions. But i also need another column to show if starting date is passed or not based on Starting Date coulumn and current date. To do that i need to cast the concatenated field (i.e Starting month) to Date.
But when i try to cast starting date as DATE, i get a error message. The sample cast function i have used is "CAST(REPLACE(CAST(YEAR(CURRENT_DATE) AS CHARACTER) ||'-'|| CASE WHEN Contact.PICK_10='Jan' THEN '01' ELSE Contact.PICK_10 END || '-' || '01', ' ', '') AS DATE)" .
Does anyone knows how to cast strings as Date? Any workarounds on this issue is appreciated.
Thanks in advance.Mark, you are not alone.
We also encountered this error using XI 3.0. We received the "Driver is not capable" error message when including date dimensions from a universe built on a BEx query. Looking at the universe, the date dimensions themselves were date fields, but all the date keys were listed as characters.
Our fix:
Replace all the date dimensions with the date keys listed below the dimensions. This is a little tricky because when you add the key into your webi query, it automatically adds the dimension. You have to manually remove the dimensions from the webi query after adding the key, and your report should run without the "Driver not capable" error message.
This is a serious bug, because now we have to train users building the webi queries to delete the date dimension. We cannot hide the dimension in the universe because it will also hide the key.
I guess another fix could be creating a new Dimension in the universe, and copying the properties from the key field into the new dimension...but if you have many dates, it's a big pain.
Hope this helps,
-Lee -
Numeric data is not displayed in BI Publisher 11g report
Hi,
I'm using Oracle BI 11g (11.1.1.6.0).
I'm experiencing a serious issue with numeric data in reports created with Publisher.
When I define the query in the data model, numeric data gets declared as "integer" (even if it should be "double"). Anyway, when creating the layout all data is correctly shown.
The issue emerges when I run the report in interactive mode: numeric data is not displayed at all.
If I run it in HTML mode or other, I get proper results.
I tried to explicitly CAST numeric data in the query to number(21, 6) but I get no different result.
Any help or suggestion is warmly welcome.
Thanks,
CristinaYes, assuming that you are using the Standalone version, following are some excerpt from user guide.
10g see Oracle® Business Intelligence Publisher
Report Designer's Guide
Release 10.1.3.4
Part No. E12187-01
Chapter 6 Building a Data Template
Supported Column Types
CLOB (conditionally supported)
The CLOB must contain text or XML. Data cannot be escaped inside the CLOB column.
And for 11g see
Oracle® Fusion Middleware
Data Modeling Guide for Oracle Business Intelligence Publisher
Release 11g (11.1.1)
Part No. E18862-01
Chapter 3 Creating Data Sets
Using Data Stored as a Character Large Object (CLOB) in a Data Model
BI Publisher supports using data stored as a character large object (CLOB) data type in
your data models. This feature enables you to use XML data generated by a separate
process and stored in your database as input to a BI Publisher data model.
Use the Query Builder to retrieve the column in your SQL query, then use the data
model editor to specify how you want the data structured. When the data model is
executed, the data engine can structure the data either as:
• a plain character set within an XML tag name that can be displayed in a report (for
example, an Item Description)
• structured XML
Cheers,
ND -
How to handle date prompt in report
Hi I have date column on database as timestamp.
Now need to apply filter in report based on date prompt.
Do i nee to cast it in Date format..or how i can do it.
thanks,Hi User,
Which versionof obiee are you in? If you are on 10.1.3.4.1 version, apply PATCH 9492821 to fix this issue.
Can you do the following checks,
In the repository physical layer, set the column to have a data type of date
In the BMM layer, where the column is mapped, edit the column mapping to contain a CAST function to cast as date
Regards,
Dpka -
Teradata database error when using a Universe-defined Date condition
I have encountered an odd problem when connecting Crystal to a Universe. There is a pre-defined Date condition built into the Universe that is defined as follows:
@Select(Date\Week End Date) > @Select(Conditions\User Response Select Date week -28) AND @Select(Date\Week End Date) <= @Select(Conditions\User Response Select Date)
The filter is designed to retrieve a rolling 4 weeks of data.
When I try and create and refresh a Crystal Report that includes this Date prompt, I get the following error:
Failed to retrieve data from the database.
Details: 22003:(ODBC Teradata Driver)(Teradata Database) A character string failed conversion to a numeric value.
If I create the same query in a WebI report it works fine, but in Crystal the error is produced. I have also tried constructing the same prompt and filter within Crystal rather than use the pre-built prompt but that did not work either.
Does anyone have any experience or advice on this error? I can't seem to find many related postings on this specific error.
BO Enterprise XI 3.1 SP2 running on Windows 2008 Server R2
Crystal Reports 2008 SP2 running on Windows XP SP3
Universe is built on a Teradata 12 source
Thanks!One item I found I had to do with Teradata was cast my date/time values to dates, otherwise I got weird errors like this. You say it's working in Web Intelligence, so this might not be the issue, but it is an easy thing to test.
In the universe, change your end date definition to
cast(table.end_date as date)
and see if that helps. -
Date format error while accessing date from SQLSERVER
Hi all, in me webdynpro application I have taken Date type for the Input Field.
At date select it is displaying in the format
*2/14/2009 i.e. mm/dd/yyyy*
And when I am saving date in the sql database then the date format changes to..
2009-02-14 i.e..yyyy/mm/dd.
But using the Date format method I have changed the format as per the need to push date in the SQL database table...
In the table SQL the date attribute is in form i.e. 02/14/2009 as like from the date select from the date Input Fieldu2026But the problem is that database is not being able to display in that Input field again.
I have use the coding both at Insertion and selection of the database i.e..
Date Sdate, Edate;
Sdate = Date.valueOf (rs.getString ("Sdate"));
Edate = Date.valueOf (rs.getString ("Edate"));
SimpleDateFormat date Formatter = new SimpleDateFormat ("MM/dd/yyyy");
Sdate = wdContext.currentProjectElement ().getEdate ();
Edate = wdContext.currentProjectElement ().getEdate ();
String Sd = dateFormatter.format (Sdate);
String Ed = dateFormatter.format (Edate);
Date Sdd =Date.valueOf (Sd);
Date Edd =Date.valueOf (Ed);
But at selection of the database the error for the date format isu2026.
java.lang.IllegalArgumentException
If somebody knows how to resolve this ,plz let me know
Regards:
SKfor displaying the value only, I think, you are converting to string.
sol1:
1. Create a simple type in dictionary: under Dictionary -> Local Dictionary -> Simple Types
2. go to Definition tab: Change Built-in Type as Date
3. go to Representation tab: specify format e.g.: MM/dd/yyyy
4. go to Context and change the date context attribute to the created type.
sol2:
please try to minimize the casting between Date and String.
I believe in database date is stored as Date type itself. My suggestion will be for displaying keep a separate attribute and set it on each db call.
below code is converting from Date to String.
Date Sdate, Edate;
Sdate = rs.getDate ("Sdate");
Edate = rs.getDate ("Edate");
SimpleDateFormat date Formatter = new SimpleDateFormat ("MM/dd/yyyy");
String Sd = dateFormatter.format (Sdate);
String Ed = dateFormatter.format (Edate);
Maybe you are looking for
-
How to find user group from tcode
Hi Experts, I have custom tcode from this i found report name as AQIDSYSTQV000001SD_RR_03====== I am unable to find Queryname in SQ01 from this. When i saw some of the forums i understood that IDSYST is the user group for my query but i am unable to
-
Issue in Hybris Catalog import in AEM
After successfully importing the catalog from hybris to AEM, I am facing the following problems (a) Renditioning of the original image passed by hybris is not working. I can find that the DAM work flow is getting triggered for performing the renditio
-
Hi, I dont know if this is the correct forum. What are the process steps that I need to take when creating test script for Clearing Vendor Item. Appreciate your help. Regards, ved
-
Same country different tax codes
In Japan there are 2 company codes.One company code is using tax code V1=7%. The other company code is using tax code V2=7%. Although the percentages are same the tax codes are different for the same country.Is there any option of maintaining this.
-
Ecrire dans un fichier excel boucle for
Bonjour à vous, Alors voilà, je réalise un stage de trois mois pour mes études et je me dois de réaliser ou plutot completer un programme labview. Celui-ci sert à piloter un spectromètre, en gros à afficher l'intensité des longueurs d'onde composant