简体   繁体   English

如何在 Postgresql 中将“MM/YY”字符串转换为日期格式“YYYY-MM-01”

[英]How to Convert A' MM/YY' String in to a date format 'YYYY-MM-01' in Postgresql

I have column of string, and it's like 'MM YY' (eg. Dec 21, Jan 22, etc..).我有一列字符串,就像“MM YY”(例如,12 月 21 日、1 月 22 日等)。 How can I convert it to a date format, YYYY-MM-DD, in Redshift.(PostgreSQL) Thanks!如何在 Redshift 中将其转换为日期格式 YYYY-MM-DD。(PostgreSQL)谢谢!

If you want to convert to Date , you can use:如果你想转换为Date ,你可以使用:

TO_DATE(column, 'Mon YY')

If you want to convert to Text (String), you can use:如果你想转换为Text (字符串),你可以使用:

TO_DATE(column, 'Mon YY')::TEXT

This uses the TO_DATE - Amazon Redshift function to "convert a date represented by a character string to a DATE data type."这使用TO_DATE - Amazon Redshift function 来“将字符串表示的日期转换为 DATE 数据类型。”

暂无
暂无

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

相关问题 如何将字符串日期 dd-mmm-yyyy hh:mm 特定格式转换为日期格式 - How to convert String date dd-mmm-yyyy hh:mm specific format to Date format 将日期 isoString "2022-12-20T21:20:23.500Z" 转换为格式 DD/MM/YYYY hh:mm in Athena sql - Convert date isoString "2022-12-20T21:20:23.500Z" to format DD/MM/YYYY hh:mm in Athena sql 无法在 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 如何在 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 如何将 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 Google Cloud Storage 中的日期格式将日期更改为 YYYY-DD-MM 格式 - Date format in Google Cloud Storage changes date to YYYY-DD-MM format 将今天的日期与 dynamodb 表中的日期格式 YYYY-DD-MM 进行比较 - comparen today's date with date format YYYY-DD-MM in dynamodb table 使用 BigQuery 将 CURRENT_TIMESTAMP 转换为 dd/mm/yyyy hh:mm 字符串 - Cast CURRENT_TIMESTAMP to dd/mm/yyyy hh:mm string with BigQuery 按年/月(格式 YYYY-MM)细分的平均订阅量(总订阅量/计数订阅)是多少? - How much is the average subscriptions amount (sum amount subscriptions / count subscriptions) breakdown by year/month (format YYYY-MM)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM