Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Fri, 25 Jan 2008 @ 08:51:46 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Cast Behavior Between 6.1 and 6.2
From:   Michael Larkins

Hello Anthony:

When using Teradata to create this table and using a date, format is actually the way you should be going:

     ct testtbl2 as (sel date (format 'yyyy')(char(4)) a
                                 ,date (format 'mm')(char(2)) b
                                 ,date (format 'dd')(char(2)) c)
     with data
     primary index (a)

This will provide the leading zeroes and you don't need to CAST it because the char specification changes the data type. You would not need the char if any other data type for these values. Since your table at the end of your posting used yearid as a smallint, however, then you would need to use a format in the select to get the leading zeroes since they are normally suppressed.


Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016