从字符串到日期的日期格式 [英] Date formatting from string to date

查看:23
本文介绍了从字符串到日期的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用上传的 csv 进行日期格式化,其中日期是一个字符串,格式为10/30/2021 8:41 PM";我试图在谷歌大查询中将其更改为mm/dd/yyyy",但不断收到错误消息,提示日期无效或日期时间无效.我试过解析它,使用子字符串,甚至删除 AM/PM 但没有用.如果您有任何想法,请告诉我,因为到目前为止我还没有在网上找到任何解决方案

I am having date formatting with an uplaoded csv where date is a string with the following formate '10/30/2021 8:41 PM'; i am trying to change it into 'mm/dd/yyyy' in google big query, but keep getting an error saying Invalid Date or Invalid datetime. I have tried parsing it, using substrings, and even dropping the AM/PM but no use. Please let me know if you have any ideas as i did not find any solution online thus far

推荐答案

从字符串到日期

考虑下面的例子

select date(parse_datetime('%m/%d/%Y %I:%M %p', '10/30/2021 8:41 PM'))          

带输出

这篇关于从字符串到日期的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆