Hi does anyone know how to convert a string in YYYYMMDD format to yyyy-mm-dd in duck db?
have tried to cast, have tried strptime(date, 'yyyymmdd'), have tried convert, to_date
You can do so like this
SELECT strftime(DATE your_string, '%Y-%m-%d');
See duckdb documentation for more information :)
You could also try converting the string first outside of duck db like so:
string.strftime('%Y-%m-%d')
and then passing it to duck db.
with a as ( select *, cast(date as text) as string_date from raw_data ) select * , strftime(date string_date, '%Y-%m-%d') from a ParserException: Parser Error: syntax error at or near "string_date" LINE 6: select * , strftime(date string_date, '%Y-%m-%d') from a ^