1

I am loading date fields from file to teradata table. In a file my date format is mm-dd-yyyy and in my teradata table the format is yyyy/mm/dd.

I used the below function for formatting:

To_date(to_char(date field,'mm-dd-yyyy'),'yyyy/mm/dd')

But all my records are going in rejected records. When I checked session log my date field was mentioned as invalid date.

Please help on this.

YePhIcK
  • 5,816
  • 2
  • 27
  • 52
  • 3
    In your input file the date column is a string? Then you don't have to do the to_char, it should be **to_date(date field, 'mm-dd-yyyy')** or **date field (date, format 'mm-de-yyyy')** – dnoeth Jul 08 '14 at 12:41
  • Thanks dnoeth I have used to_date(datefield,'mm-dd-yyyy ') and it worked. – Rekha Goverthanam Jul 09 '14 at 13:20

2 Answers2

0

just use to_date('12-31-2014','mm-dd-yyyy'); It will work

dev
  • 732
  • 2
  • 8
  • 29
0

Please use this function.

v_PORT(DateTime)-TO_DATE(TO_CHAR(INPUTPORT),'MM-DD-YYYY')
   o_PORT(String)--TO_CHAR(v_PORT,'YYYY/MM/DD')

It's working.

dnoeth
  • 59,503
  • 4
  • 39
  • 56