Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform GCP BigQUery日历表-会计年度和月份_Google Cloud Platform_Google Bigquery - Fatal编程技术网

Google cloud platform GCP BigQUery日历表-会计年度和月份

Google cloud platform GCP BigQUery日历表-会计年度和月份,google-cloud-platform,google-bigquery,Google Cloud Platform,Google Bigquery,我正在Biquery中构建一个日历表。如何在GCP BigQuery中从日历日期获取会计月和会计年? 财政年度-7月至6月 下面是我到目前为止使用的SQL SELECT date, FORMAT_DATE("%A", date) as Day_OF_WEEK, EXTRACT(DAY FROM date) as the_day, EXTRACT(MONTH FROM date) as the_month, EXTRACT(YEAR FROM date)

我正在Biquery中构建一个日历表。如何在GCP BigQuery中从日历日期获取会计月和会计年? 财政年度-7月至6月 下面是我到目前为止使用的SQL


SELECT
  date,
  FORMAT_DATE("%A", date) as Day_OF_WEEK,
  EXTRACT(DAY FROM date) as the_day,
  EXTRACT(MONTH FROM date) as the_month,
  EXTRACT(YEAR FROM date) AS year,
  FORMAT_DATE("%b", date) as Month_Name,
  FORMAT_DATE("%B", date) as Month_Name_Full,
  EXTRACT(WEEK FROM date) AS week,
 FORMAT_DATE("%d-%m-%E4Y", date) as Date_DDMMYYYY,
 FORMAT_DATE("%Y%m", date) as Date_YYYYMM,
 FORMAT_DATE("%Y-%m", date) as Date_YYYY_MM,
 FORMAT_DATE("%m-%Y", date) as Date_MM_YYYY,

How do I get this?
 --FORMAT_DATE("%Y%m", date) as FISCALMonth,
 --FORMAT_DATE("%Y%m", date) as FISCALYEAR,
 
 FROM UNNEST(GENERATE_DATE_ARRAY('2010-01-01', '2050-12-31')) AS Date
ORDER BY date;

输出


您好,答案很有帮助。但是,假设我的财政年度是2020年6月1日至2021年5月31日,即2021年。我们需要改变以上的逻辑,我想我们也必须继续跟踪这一年。请就这一要求提供一些建议。谢谢
SELECT
  date,
  extract(month from date) as calendar_month,
  extract(year from date) as calendar_year,
  extract(month from date_add(date, interval 6 month)) as fiscal_month,
  extract(year from date_add(date, interval 6 month)) as fiscal_year,
from unnest(generate_date_array('2020-01-01', '2021-12-31', interval 1 month)) as date
order by date;