-->

INFORMATICA - Date format conversion

2019-09-21 03:45发布

问题:

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 .

回答1:

Use the function TO_DATE

TO_DATE(Column_name, 'mm/dd/yyyy')


回答2:

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'.



回答3:

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'.



回答4:

   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.



回答5:

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') 


标签: informatica