How to fix string conversion to date? - informatica-powercenter

my requirement is to convert a string field to date in filter transformation so that i could further compare it with another date but unable to fix the conversion.
Below is the code which i tried .In which i am firstly checking whether it's the correct date format or not using "IS_DATE". This expression is not giving error and being parsed successfully but when i try to convert it to date, it's giving Error "assignment error, Incompatible data types. Field is integer expression is date/time". Not sure what's wrong if "IS_DATE" function is working fine.
IIF(IS_DATE(HIRE_DATE,'MM/DD/YYYY HH24:MI:SS' ),TO_DATE(HIRE_DATE,'MM/DD/YYYY HH24:MI:SS' ))

Change the port type to date. Currently it would be int.

Related

I can't add a data date value to firebird when the day portion is greater than 12

I have an odd problem about VB6.0 programming when I add a value to database firebird from DtPicker or Calendar. When I add a date where the day is 1 to 12 it can add it into the database, but when I try to add a date where the day is the 13th or above it shows error message
Run-time error '-2147467259'(80004005)':
[ODBC Firebird Driver][Firebird]conversion error from string "13/08/2017"
The type in database is "DATE", but when I turn the type in database into "VARCHAR" everything is fine, but "VARCHAR" cannot do the function Date.
If you pass date value as a string or in context of a concatenated statement, make sure you set the value in 'YYYY-MM-DD' format (ISO_8601).
If you have prepared statements with parameters, then driver itself will handle safely data type conversions automagically. At least it should.
Last option is recommended.

Oracle to_timestamp produces error

I am trying to get a value of time-stamp column using jdbc driver. The following query works like a charm :
to_char(update_date,'YYYY-MM-DD HH24:MI:SS.FF9 TZR') update_date
However, instead of to_char, I need timestamp values and if I use the following query in my select statemnt, it gives
OTA-01821-Date format not recognized
error. please can someone help?
to_timestamp(update_date,'YYYY-MM-DD HH24:MI:SS.FF9 TZR') update_date
The immediate cause of the error is the TZR part of the format mask, which isn't valid for a plain timestamp. You could either convert to a timestamp with time zone with a different function:
to_timestamp_tz(update_date,'YYYY-MM-DD HH24:MI:SS.FF9 TZR')
or omit the time zone:
to_timestamp(update_date,'YYYY-MM-DD HH24:MI:SS.FF9')
But as uodate_date is already a timestamp (with [local] time zone), you are implicitly converting it to a string using your session's NLS_TIMESTAMP_TZ_FORMAT setting, before explicitly converting that string back to a timestamp (with or without time zone).
At best this is pointless, but if your NLS setting doesn't match the explicit format you use then it will give a different error or incorrect results.
If you want a timestamp value from Java then don't do any conversion - just select the original update_date column, and use the JDBC getTimestamp() to retrieve it.

date format with inconsistant data Oracle SQL

I am have a freetext column which a date is input to.
is there a way i can force the output to display the same?
for example some people are entering '2/12/15' others are entering '02/12/2015'
how i can i get the output to pick up the dates and change them to a consistant format?
no idea where to start. I have tried "To_char" but it says 'invalid number'
Actually I believe you want to_date( ):
select to_date('2/12/15', 'mm/dd/rrrr')
from dual;
The 'rrrr' for year will format the year correctly. See date formats here: https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements004.htm
Your best approach here may be to use a PL/SQL function that accepts the string and then attempts a series of date conversions on it with different date format pictures ('DD/MM/YY', 'DD/MM/YYYY' etc) until it finds one that does not raise an exception.
This won't work if some people enter DD/MM/YYYY and others enter MM/DD/YYYY, but will appear to in some cases.

Matching date format in Teradata YYYY-MM-DD

I am fairly new to Teradata. I have a transaction date column in the source which has some valid and invalid values. What I need to do is fetch the valid values which are in the format YYYY-MM-DD HH:MM:SS.SSSSSS and pass a null to target for all the invalid values
The transformation rule is : If format YYYY-MM-DD HH:MM:SS.SSSSSS then move source to target else move null to target.
Just left join your column with the Sys_Calendar tables, and using COALESCE in the SEL part should get it to work.
If you still have issues, cast your date into a format that matches sys calendar.
Invalid dates will be returned as NULL.

How to use the "to_date" function in Oracle with a variable as parameter?

I have a stored procedure that contains the following:
V_DATACONVERTIDA varchar2(100) := TO_DATE('27/10/1994 23:59:59', 'DD/MM/YYYY HH24:MI:SS.SSSSS');
It works fine, but the problem is I gotta make that date a variable. So I created
V_DATAEXPIRACAO VARCHAR2(100) := p__formdata;
being p__formdata (varchar2) a parameter from the SP.
When I made that change, though, I got the following error:
ORA-01858: a non-numeric character was found where a numeric was expected
" I don't understand why it says it expects a numeric value when
everything is supposed to be string (or varchar)"
Well clearly everything isn't a string. Oracle hurls the ORA-01858 error we attempt to cast a string to a date but with wrong format mask; for instance this example passes a character month but specifies a numeric month in the mask: to_date('08-APR-2013', 'DD-MM-YYYY') .
So, if you're getting that error your program isn't doing what you think it is. But only you can see the whole source, so only you can figure out where the bug lies.

Resources