0

How do I convert a numeric in Julian format 'yyyyddd' to a proper Date value in Teradata? For example from '2014001' to '2014-01-01'.

Please provide two examples, first when '2014001' is a numeric and second when it is a character.

Many Thanks!

Damian Yerrick
  • 4,602
  • 2
  • 26
  • 64
Peter Xu
  • 55
  • 3
  • 10

1 Answers1

1

After some trial-and-error I've found the answer.

If the data is character, then:

Cast(<Column Name> As Date Format ‘yyyyddd’) 

If the data is numeric, then:

Cast(Cast(<Column Name> As Char(7)) As Date Format ‘yyyyddd’) 
Peter Xu
  • 55
  • 3
  • 10