String to Date

TO_DATE converts a date represented in a character string to a DATE data type.

The second argument is a format string that indicates how the character string should be parsed to create the date value.

Syntax: TO_DATE(string, format)

The following can be modified for any datetime separators (such as ‘-‘, ‘/’, or ‘:’):

Date as input Function Call
2017/02/08 TO_DATE(date, 'YYYY/MM/DD')
08/02/2017 TO_DATE(date, 'DD/MM/YYYY')
08-02-2017 TO_DATE(date, ‘DD-MM-YYYY’’)
02082017 TO_DATE(date', 'MMDDYY')
08 Feb 2017 TO_DATE(date, 'DD MM YYYY')
18:45:09 TO_DATE(date, 'HH24:MI:SS')


String to Number

Number as input Function call
5 CAST(number AS integer)

or alternatively number::integer

or alternatively

convert(integer, number)

2.3 CAST(number AS decimal(1,1))

It is important to specify correctly the precision you want. For example, for input 2.33 you should choose CAST(number AS decimal(1,2)).

in SQL Playbook