Reputation: 33
Attempting to convert a variable character data type field that is time related (eg '2015-Q1'
) to a timestamp (or time) data type field in order to compare with a different field.
Need to be able to use dateadd()
on the field.
Upvotes: 3
Views: 6781
Reputation: 508
Use the TO_DATE
function: https://docs.aws.amazon.com/redshift/latest/dg/r_TO_DATE_function.html
https://docs.aws.amazon.com/redshift/latest/dg/r_FORMAT_strings.html
Along with TO_TIMESTAMP
https://docs.aws.amazon.com/redshift/latest/dg/r_TO_TIMESTAMP.html
example:
select to_timestamp(to_date('2015-Q1', 'YYYY-MM-DD'), 'HH24:MI:SS')
;
Upvotes: 1