简体   繁体   中英

Teradata SQL numeric to timestamp or date

I need to change a column that looks like this =" 202007211330231166 " into time stamp or date format = 21/07/2020 & time = 1:30 pm ie (1330 <- part) Help. I was attempting to use Substring to capture the date & time sections.

select InfoData from dbc.dbcinfoV where InfoKey = 'RELEASE'; = version of Teradata 16.20.53.13

You're on the right track, split the string and then CAST it:

cast(substring(col from 1 for 8) as date format 'yyyymmdd')
cast(substring(col from 9 for 4) as time(0) format 'hhmi')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM