[英]How to get 10,000 years (max) interval in days?
To get 10,000 years -- the max interval value -- I can use year
or month
:要获得 10,000 年——最大间隔值——我可以使用year
或month
:
SELECT INTERVAL 10000 year, INTERVAL 10000*12 month
What is the value that I would use for day
to get the 10,000 year value?我将使用什么值来获得 10,000 年day
值? Any variation I've tried of it either does not convert-up from day to year or overflows (if I go beyond).我尝试过的任何变体要么不会逐年转换,要么会溢出(如果我超出 go 的话)。 Is there a way to convert day into year in the output, or BQ never converts it?有没有办法在 output 中将日转换为年,或者 BQ 从不转换它?
As an example:举个例子:
From JUSTIFY_DAYS documentation:来自JUSTIFY_DAYS文档:
Normalizes the day part of the interval to the range from -29 to 29 by incrementing/decrementing the month or year part of the interval.通过增加/减少间隔的月或年部分,将间隔的日部分标准化为-29 到 29的范围。
INTERVAL 1 MONTH
is same as INTERVAL 30 DAY
and therfore INTERVAL 1 YEAR
will be INTERVAL 30 DAY * 12
which is INTERVAL 360 DAY
. INTERVAL 1 MONTH
与INTERVAL 30 DAY
相同,因此INTERVAL 1 YEAR
将是INTERVAL 30 DAY * 12
即INTERVAL 360 DAY
。
SELECT INTERVAL 1 MONTH = INTERVAL 30 DAY month_is_30,
INTERVAL 1 MONTH = INTERVAL 31 DAY month_is_31,
INTERVAL 1 YEAR = INTERVAL 360 DAY year_is_360,
INTERVAL 1 YEAR = INTERVAL 365 DAY year_is_365,
+-------------+-------------+-------------+-------------+
| month_is_30 | month_is_31 | year_is_360 | year_is_365 |
+-------------+-------------+-------------+-------------+
| true | false | true | false |
+-------------+-------------+-------------+-------------+
What is the value that I would use for day to get the 10,000 year value?我将使用什么值来获得 10,000 年的值?
SELECT INTERVAL 10000 * 360 DAY days,
JUSTIFY_DAYS(INTERVAL 10000 * 360 DAY) max_years;
+-------------------+-----------------+
| days | max_years |
+-------------------+-----------------+
| 0-0 3600000 0:0:0 | 10000-0 0 0:0:0 |
+-------------------+-----------------+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.