简体   繁体   English

如何将 varchar 数据类型中的列更改为时间戳? 列中的数据格式为 'yyyy-mm-ddThh:mm:ss

[英]How to alter column in varchar datatype to timestamp? The data in the column are in the format 'yyyy-mm-ddThh:mm:ss

Given the below sample data, what will be the alter column clause in Redshift to change it to timestamp?给定以下示例数据,Redshift 中将其更改为时间戳的 alter column 子句是什么? currently it is in varchar目前它在varchar中

timestamp时间戳
2021-11-23T13:39:54+00:00 2021-11-23T13:39:54+00:00
2021-11-23T14:16:25+00:00 2021-11-23T14:16:25+00:00

Try this:尝试这个:

cast(column_name as timestamp)

You can read about it here:你可以在这里读到它:

https://devdocs.io/postgresql~9.4/sql-expressions#SQL-SYNTAX-TYPE-CASTS https://devdocs.io/postgresql~9.4/sql-expressions#SQL-SYNTAX-TYPE-CASTS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure 数据工厂中将活动 output 格式化为 YYYY-MM-DD hh:mm:ss - How to format an activity output as YYYY-MM-DD hh:mm:ss in Azure data factory 如何在 BigQuery 中将时间戳列转换为 MM/DD/YYYY - How do I cast a timestamp column as a MM/DD/YYYY in BigQuery 无法在 pyspark 中将纪元时间戳转换为“dd-mm-yyyy HH:mm:ss”格式 - Unable to convert epoch timestamp into "dd-mm-yyyy HH:mm:ss" format in pyspark 如何将 yyyy-mm-dd hh:MM:SS.mil 形式的时间戳转换为 Athena 中的纪元时间 - How to convert timestamp in the form of yyyy-mm-dd hh:MM:SS.mil to epoch time in Athena 如何更改 BigQuery 中列的数据类型 - How to alter datatype of a column in BigQuery Fireabse Cloud Functions 时间戳为“MM、DD、YYYY” - Fireabse Cloud Functions timestamp to 'MM,DD,YYYY' 如何在 Postgresql 中将“MM/YY”字符串转换为日期格式“YYYY-MM-01” - How to Convert A' MM/YY' String in to a date format 'YYYY-MM-01' in Postgresql 如何将字符串日期 dd-mmm-yyyy hh:mm 特定格式转换为日期格式 - How to convert String date dd-mmm-yyyy hh:mm specific format to Date format DataStudio 和 SQL 将时间格式从数字更改为 hh:mm:ss - DataStudio and SQL change time format from numbers to hh:mm:ss 有没有办法减去 2 个时间戳并在 Redshift 中以 'hh:mm:ss' 格式获得结果 - Is there a way to subtract 2 timestamps and get the result in 'hh:mm:ss' format in Redshift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM