简体   繁体   English

在 Google Data studio/Looker Studio 中获取 ISO 周数的结束日期

[英]Get the end date for an ISO week number in Google Data studio/Looker Studio

I google data studio, I have a field called week that contains the week number the value is string 'Week 2' for example.我用谷歌数据工作室,我有一个名为 week 的字段,其中包含周数,例如,值为字符串“Week 2”。 How can I extract the last day of the week based on the week number.如何根据周数提取一周的最后一天。 In this case I want to get 2023-01-14 which is the last day of week 2?在这种情况下,我想获得 2023-01-14,这是第 2 周的最后一天?

Have you tried the last_day function?你试过last_day function了吗?

I would build from the using the date using last_day, because from the week number it would require a bit more code.我将从使用 last_day 的日期开始构建,因为从周数开始它需要更多代码。

SELECT *, 
  LAST_DAY(today, WEEK) AS last_day_of_week, 
  EXTRACT(WEEK FROM today) AS week_number

FROM (SELECT CURRENT_DATE() AS today)

But if you need to go with just the week number, I recommend taking a look into this other question How to create date based on year, week number and day in bigquery .但是,如果您只需要周数 go,我建议您查看另一个问题How to create date based on year, week number and day in bigquery

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

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