Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Fri, 26 Mar 2004 @ 11:01:25 GMT

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

Subj:   Re: Date out of date time fields
From:   David Wellman


A couple of ways come to mind.

(1) use SUBSTRING and CAST:

- using CURRENT_TIMESTAMP as an example (which is TIMESTAMP(6) WITH TIMEZONE <== i.e. 33 characters)

- select cast(substring(cast(current_timestamp as char(33)) from 1 for 10) as date format 'yyyy-mm-dd')

(2) use EXTRACT function to extract the date components and then piece them back together as a DATE column

- select cast((
       (extract(year from current_timestamp)-1900) * 10000
      + extract(month from current_timestamp) * 100
      + extract(day from current_timestamp)
       ) as date)



Ward Analytics Ltd: Information in motion (www.ward-analytics.com)

  <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: 23 Jun 2019