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 3 months ago * This page is subject to Site terms.

More from Kontext

local_offer teradata local_offer python

visibility 209
thumb_up 0
access_time 2 months ago

Pandas is commonly used by Python users to perform data operations. In many scenarios, the results need to be saved to a storage like Teradata. This article shows you how to do that easily using JayDeBeApi or  ...

open_in_new View open_in_new Spark + PySpark

local_offer teradata local_offer SQL

visibility 29
thumb_up 0
access_time 2 months ago

In SQL Server, we can use TRUNCATE statement to clear all the records in a table and it usually performs better compared with DELETE statements as no transaction log for each individual row deletion. The syntax looks like the following: TRUNCATE TABLE { database_name.schema_name.tab...

open_in_new View open_in_new Code snippets

local_offer teradata local_offer python local_offer Java

visibility 135
thumb_up 0
access_time 2 months ago

Python JayDeBeApi module allows you to connect from Python to Teradata databases using Java JDBC drivers. In article Connect to Teradata database through Python , I showed ho...

open_in_new View open_in_new Python Programming

local_offer teradata local_offer SQL

visibility 127
thumb_up 0
access_time 3 months ago

OREPLACE functions in Teradata can be used to replace or remove characters from a string. OREPACE is Teradata's extension to ASNI SQL. The usual REPLACE function is not available. ANSI SQL REPLACE function REPLACE function is commonly implemented in many other SQL databases such as ...

open_in_new View open_in_new Code snippets

info About author

Dark theme mode

Dark theme mode is available on Kontext.

Learn more arrow_forward

Kontext Column

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


Learn more arrow_forward