简体   繁体   English

如何在 BigQuery 中将时间戳格式化为带小数秒的字符串?

[英]How to format a timestamp to string with fractional seconds in BigQuery?

This is a pretty straightforward question that I cannot seem to find the answer to.这是一个非常简单的问题,我似乎无法找到答案。

I am working in BigQuery and have a timestamp:我在 BigQuery 工作并且有一个时间戳:

2022-01-02 13:00:01.5849

I want to convert this to a string with all dashes, colons and spaces removed.我想将其转换为删除所有破折号、冒号和空格的字符串。 End result should look like this:最终结果应该是这样的:

202201021300015849

I am able to get everything before the decimal formatted fine but can't seem to figure out how to grab the fractional seconds.我能够得到小数点前的所有格式,但似乎无法弄清楚如何获取小数秒。

This is what I have working so far:这是我目前所做的工作:

SELECT FORMAT_DATE('%Y%m%d%H%M%S', timestamp '2022-01-02 13:00:01.5849')

The output of this is:这个的output是:

20220102130001

Obviously this is missing the.5849 fractional seconds显然这缺少.5849 小数秒

Thank you谢谢

Use below在下面使用

SELECT REPLACE(FORMAT_DATE('%Y%m%d%H%M%E*S', timestamp '2022-01-02 13:00:01.5849'), '.', '')

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

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