This code snippet shows how to convert string to date.

In Teradata, CAST function can be used to cast string/varchar to date. Format string can be used. For example, B represents blank/space while YYYY represents years.

Code snippet

SELECT CAST('2017-10-15' AS DATE FORMAT 'YYYY-MM-DD');

SELECT CAST('2017 10 15' AS DATE FORMAT 'YYYYBMMBDD');

SELECT CAST('2017 Oct 15' AS DATE FORMAT 'YYYYBMMMBDD');

SELECT CAST('15, Oct, 2017' AS DATE FORMAT 'DD,BMMM,BYYYY');

-- default ansi format

SELECT CAST('2017-10-15' AS DATE);

-- use to_date function

SELECT to_date('2017-10-15', 'YYYY-MM-DD');
info Last modified by Raymond at 5 months ago copyright This page is subject to Site terms.

More from Kontext

local_offer teradata local_offer SQL

visibility 9
thumb_up 0
access_time 11 days ago

The following code snippets show how to use round numbers to hundreds or thousands in Teradata.  warning Alert - The following code snippets are used to round to the smallest hundreds or thousands that is equal or greater than the i...

open_in_new Code snippets

local_offer teradata local_offer SQL

visibility 14
thumb_up 0
access_time 11 days ago

In article   Teradata SQL...

open_in_new Code snippets

local_offer teradata local_offer SQL

visibility 11
thumb_up 0
access_time 11 days ago

This page shows you how to use LIKE

open_in_new Code snippets

local_offer teradata local_offer SQL

visibility 10
thumb_up 0
access_time 11 days ago

This page shows how to trim or remove leading or/and trailing zeros using Teradata SQL.

open_in_new Code snippets

comment Comments (0)

comment Add comment

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

No comments yet.

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.


Learn more arrow_forward