如何使用Regex替换Google Data Studio中日期字段中的方括号? [英] How to use Regex to replace square brackets from date field in Google Data Studio?

查看:86
本文介绍了如何使用Regex替换Google Data Studio中日期字段中的方括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google Data Studio中删除日期字段周围的方括号,以便将其适当地视为正确的日期维度.

I am trying to remove square brackets around a date field in Google Data Studio so I can properly treat it as a proper date dimension.

它看起来像这样:

[2020-05-20 00:00:23]

,并且我正在使用REGEXP_REPLACE(Date, "/[\[\]']+/g", "")的RegEx,我希望它的输出看起来像这样:

and I am using the RegEx of REGEXP_REPLACE(Date, "/[\[\]']+/g", "") and I want it to look like this for the output:

2020-05-20 00:00:23

它不断给我错误结果,并且不起作用.我无法弄清楚我在做什么错,我使用了 https://www.regextester.com/确认它可以正常工作

It keeps giving me error results and will not work. I can not figure out what I am doing wrong here, I've used https://www.regextester.com/ to verify that it should work

推荐答案

关于日期,可以使用单个日期 计算字段:

Regarding Dates, it can be achieved with a single TODATE Calculated Field:

TODATE(Date, "[%Y-%m-%d %H:%M:%S]", "%Y%m%d%H%M%S")

然后可以根据需要设置日期类型:

The Date Type can then be set as required:

  • YYYYMMDD :日期
  • YYYYMMDDhh :日期小时
  • YYYYMMDDhhmm :日期时分

Google Data Studio报告和GIF进行详细说明:

Google Data Studio Report and GIF to elaborate:

这篇关于如何使用Regex替换Google Data Studio中日期字段中的方括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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