Input looks like:
2017-07-03
Expected output looks like:
20170703
I tried the below code:
year(2017-07-03) * 10000 + month(2017-07-03) * 100 + day(2017-07-03))
Is there any built-in function that can do this conversion?
Thank you
Input looks like:
2017-07-03
Expected output looks like:
20170703
I tried the below code:
year(2017-07-03) * 10000 + month(2017-07-03) * 100 + day(2017-07-03))
Is there any built-in function that can do this conversion?
Thank you
You can use from_unixtime
and unix_timestamp
with cast
to do this.
select cast(from_unixtime(unix_timestamp('2017-07-03','yyyy-MM-dd'),'yyyyMMdd') as int)
You can split on '-', then concatenate back again. Or replace "-" with "".
regexp_replace("2017-07-03", "-", "")