Date format in Informatica expression - informatica

In Informatica I use the below expression:
IIF( PARAMETER_NAME='$$CURRENT_DATE_IN_SQL_FORMAT',TO_CHAR(SYSDATE,'YYYY-MM-DD'),'PARAMETER_VALUE')
which give me the date in format 2021-11-25
But I need it me to return value as below format
TO_DATE('2021-11-25', 'YYYY-MM-DD')
Any help is much appreciated
Thanks

You can use below expression.
IIF( PARAMETER_NAME='$$CURRENT_DATE_IN_SQL_FORMAT',
'TO_DATE('|| CHR(39)||
TO_CHAR(SYSDATE,'YYYY-MM-DD')||chr(39)||','||chr(39)||'YYYY-MM-DD'||chr(39)||')',
,'PARAMETER_VALUE')
You can calculate your expected output by concatenating quote, and ||.

Related

Informatica date format

I convert string to date format in informatica using expression transformation
TO_DATE(input_field_string,'MM/DD/YYYY HH:MI:SS '). And I want to round off the MM/DD/YYYY/ HH:MI. how do I do this using expression transformation. For example my data is 10/10/2015 10:05:09. I want to convert this to 10/10/2015 10:00 using expression.
Feed the result of your TO_DATE expression (lets call this v_Date) in a TO_CHAR function i.e. TO_CHAR (v_Date, 'MM/DD/YYYY HH24:MI' )

Regular Expression in redshift

I have a data which is being fed in the below format -
2016-006-011 04:58:22.058
This is an incorrect date/timestamp format and in order to convert this to a right one as below -
2016-06-11 04:58:22.058
I'm trying to achieve this using regex in redshift. Is there a way to remove the additional Zero(0) in the date and month portion using regex. I need something more generic and not tailed for this example alone as date will vary.
The function regexp_replace() (see documentation) should do the trick:
select
regexp_replace(
'2016-006-011 04:58:22.058' -- use your date column here instead
, '\-0([0-9]{2}\-)0([0-9]{2})' -- matches "-006-011", captures "06-" in $1, "11" in $2
, '-$1$2' -- inserts $1 and $2 to give "-06-11"
)
;
And so the result is, as required:
regexp_replace
-------------------------
2016-06-11 04:58:22.058
(1 row)

INFORMATICA - Date format conversion

Hello guys i have a date format of 12/05/2015 i.e., dd/mm/yyyy . I need to convert this as 05/12/2015 i.e., mm/dd/yyyy . Can any one give me a solution .
Because function TO_DATE by default expects the date as a char value to be in the form 'MM/DD/YYYY', you need to specify you're handing it in as 'DD/MM/YYYY'. Then you want the final output to be a string (presumably) in format 'MM/DD/YYYY', so for that you need the function TO_CHAR. So you have to jump that hurdle, too. The final statement for your example, then, looks like this:
TO_CHAR(TO_DATE('12/05/2015', 'DD/MM/YYYY'), 'MM/DD/YYYY')
The output will be '05/12/2015'.
Use the function TO_DATE
TO_DATE(Column_name, 'mm/dd/yyyy')
In informatica Help file, There is a chapter called "functions". In that check TO_DATE function.
TO_DATE( string [, format] )
String ---- Must be a string datatype. Passes the values that you want to convert to dates. You can enter any valid transformation expression.
format ---- Enter a valid TO_DATE format string. The format string must match the parts of the string argument. For example, if you pass the string '20150515', you must use the format string 'YYYYMMDD'.
v_PORT(DataType-DateTime)-TO_DATE(TO_CHAR(INPUTPORT),'DD/MM/YYYY')
o_PORT(String)--TO_CHAR(v_PORT,'MM/DD/YYYY')
It will work.
Use the below command, this will give you the value as per you requirement
TO_CHAR(TO_DATE(Column, 'DD/MM/YYYY'), 'MM/DD/YYYY')

Oracle SQL regexp date formatting

im so new in oracle, and trying to select some bad formatted date as cleaned.
for example,
my field is: 12.05.2010 dfsafs()F(Gf, 12:45
can i select it as 12.05.2010 12:45 with regexp or something else ?
thanks
Use the below regex to match date and time formats.
[0-9]{2}\.[0-9]{2}\.[0-9]{4}|[0-9]{2}:[0-9]{2}
DEMO
In oracle, i think you need to escape the curly braces.
[0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{4\}|[0-9]\{2\}:[0-9]\{2\}
Something like this should works:
select regexp_substr(dat,'.*(\d{2}\.\d{2}\.\d{4}).*',1,1,'i',1) ||' '||
regexp_substr(dat,'.*(\d{2}:\d{2}).*',1,1,'i',1) datetime
from
(select '12.05.2010 dfsafs()F(Gf, 12:45' dat from dual);
Check that i extract date and time using regexp_substr and then concat both values.

regular expression clob field

I have a question related to an regular expression in oracle 10.
Assuming I have a value like 123456;12345;454545 stored in a clob field, is there a way via an regular expression to only filter on the second pattern (12345) knowing that the value can be more then 5 digits but always occurs after the first semicolon and always has a trailing semicolon at the end?
Thanks a lot for your support in that matter,
Have a nice day,
This query should give you your desired output.
SELECT REGEXP_REPLACE(REGEXP_SUBSTR('123456;12345;454545;45634',';[0-9]+;'),';')
FROM dual;
You can get filter any pattern using this query just change 2 to any value, but it should be less than or equal to the number of elements in the string
with tab(value) as
(select '123456;12345;454545' from dual)
select regexp_substr(value, '[^;]+', 1, 2) from tab;
easily by one call:
select regexp_replace('123456;12345;454545','^[0-9]+;([0-9]+);.*$','\1')
from dual;
perhaps, regexp expression can be modified in a way of more good-looking or your business logic, but the idea, I think, is clear.
select regexp_replace(regexp_substr(Col_name,';\d+;'),';','') from your_table;