可用的间隔输出格式消除歧义? [英] interval output format available that removes ambiguity ?

查看:61
本文介绍了可用的间隔输出格式消除歧义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要输出间隔(在这种情况下是年龄)。

PostgreSQL非常注意正确处理月份(例如

考虑到不同月份的长度) 。如果间隔的任何一个终点或起点已知为b $ b,则这只是

。对于后期处理的一些含糊不清的内容

" 2 mons"如果61天,将删除手段。返回。


有没有办法告诉PostgreSQL返回那种类型的

间隔(例如使用周,日,小时,分钟,秒,。 ..

但不是几个月,也许甚至不是几年[闰年等])?

to_char(区间,文本)不能正常工作

事实。


Karsten

-

GPG密钥ID E4071346 @ wwwkeys.pgp .net

E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

------------------ ---------(广播结束)---------------------------

提示7:别忘了增加你的免费空间地图设置

I have the need to output intervals (ages in this case).
PostgreSQL takes great care to handle months correctly (eg
take into account varying months lengths). This is only
possible if either end point or start point of an interval are
known. For post processing some of the ambiguity of what
"2 mons" means would be removed if "61 days" was returned.

Is there a way to tell PostgreSQL to return that type of
interval (eg use weeks, days, hours, minutes, seconds, ...
but not months and perhaps not even years [leap years, etc]) ?
to_char(interval, text) doesn''t work as it is applied after
the fact.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

---------------------------(end of broadcast)---------------------------
TIP 7: don''t forget to increase your free space map settings

推荐答案

2004年5月4日星期二12:24 :37 +0200,

Karsten Hilbert< Ka ************* @ gmx.net>写道:
On Tue, May 04, 2004 at 12:24:37 +0200,
Karsten Hilbert <Ka*************@gmx.net> wrote:
我需要输出间隔(在这种情况下为年龄)。
PostgreSQL非常谨慎地处理几个月(例如
考虑到不同月份的长度)。只有当间隔的任何一个终点或起点已知时,才可能这样做。对于后期处理的一些含糊之处
2 mons如果61天,将删除手段。被退回了。


现在这样做了,但是间隔的几个月部分将是

,视为30天。

是有一种方法可以告诉PostgreSQL返回那种类型的
间隔(例如使用周,日,小时,分钟,秒,......
但不是几个月,也许甚至不是几年[闰年等] )?
to_char(区间,文本)不能正常工作后使用。
I have the need to output intervals (ages in this case).
PostgreSQL takes great care to handle months correctly (eg
take into account varying months lengths). This is only
possible if either end point or start point of an interval are
known. For post processing some of the ambiguity of what
"2 mons" means would be removed if "61 days" was returned.
This is sort of done now, but the months part of the interval will be
treated as 30 days.
Is there a way to tell PostgreSQL to return that type of
interval (eg use weeks, days, hours, minutes, seconds, ...
but not months and perhaps not even years [leap years, etc]) ?
to_char(interval, text) doesn''t work as it is applied after
the fact.




你可以提取划时代"从间隔中获取间隔中的总数

秒(将月份转换为30天内的秒数

),然后除以适当的金额。


---------------------------(播出结束)------ ---------------------

提示7:别忘了增加免费空间地图设置



You can extract "epoch" from the interval to get the total number of
seconds in the interval (converting months to the number of seconds
in 30 days) and then divide that by the appropiate amount.

---------------------------(end of broadcast)---------------------------
TIP 7: don''t forget to increase your free space map settings


2004年5月4日星期二12:24:37 +0200,

Karsten Hilbert< Ka ******** *****@gmx.net>写道:
On Tue, May 04, 2004 at 12:24:37 +0200,
Karsten Hilbert <Ka*************@gmx.net> wrote:
我需要输出间隔(在这种情况下为年龄)。
PostgreSQL非常谨慎地处理几个月(例如
考虑到不同月份的长度)。只有当间隔的任何一个终点或起点已知时,才可能这样做。对于后期处理的一些含糊之处
2 mons如果61天,将删除手段。被退回了。


现在这样做了,但是间隔的几个月部分将是

,视为30天。

是有一种方法可以告诉PostgreSQL返回那种类型的
间隔(例如使用周,日,小时,分钟,秒,......
但不是几个月,也许甚至不是几年[闰年等] )?
to_char(区间,文本)不能正常工作后使用。
I have the need to output intervals (ages in this case).
PostgreSQL takes great care to handle months correctly (eg
take into account varying months lengths). This is only
possible if either end point or start point of an interval are
known. For post processing some of the ambiguity of what
"2 mons" means would be removed if "61 days" was returned.
This is sort of done now, but the months part of the interval will be
treated as 30 days.
Is there a way to tell PostgreSQL to return that type of
interval (eg use weeks, days, hours, minutes, seconds, ...
but not months and perhaps not even years [leap years, etc]) ?
to_char(interval, text) doesn''t work as it is applied after
the fact.




你可以提取划时代"从间隔中获取间隔中的总数

秒(将月份转换为30天内的秒数

),然后除以适当的金额。


---------------------------(播出结束)------ ---------------------

提示7:别忘了增加免费空间地图设置



You can extract "epoch" from the interval to get the total number of
seconds in the interval (converting months to the number of seconds
in 30 days) and then divide that by the appropiate amount.

---------------------------(end of broadcast)---------------------------
TIP 7: don''t forget to increase your free space map settings


Bruno,


感谢您的回答。我还有一些问题:
Bruno,

thanks for answering. I still have some questions:
我需要输出间隔(在这种情况下为年龄)。
PostgreSQL非常谨慎处理几个月正确(例如
考虑到不同月份的长度)。只有当间隔的任何一个终点或起点已知时,才可能这样做。对于后期处理的一些含糊之处
2 mons如果61天,将删除手段。返回了。
现在已经完成了,但间隔的几个月部分将被视为30天。
I have the need to output intervals (ages in this case).
PostgreSQL takes great care to handle months correctly (eg
take into account varying months lengths). This is only
possible if either end point or start point of an interval are
known. For post processing some of the ambiguity of what
"2 mons" means would be removed if "61 days" was returned.
This is sort of done now, but the months part of the interval will be
treated as 30 days.



你是说当PostgreSQL返回... 3 mons ...

作为区间的表示我可以安全地假设

计算它使用的月数30天

无论月份的实际长度如何?我找不到

这个号码在任何地方提到过,而且还没有浏览过来源

呢。这也与我的想法相反。我假设

会发生以下情况:


选择年龄(''1999-2-2'',''1999-3-2'') ;

选择年龄(''1999-5-2'',''1999-6-2'');


都会返回 1个星期一(尽管第一个是28天

,第二个是31天)。


我现在正在寻找一种说法:


选择年龄(''1999-2-2'',''1999-3-2'',没有月份);

select age(''1999 -5-2'',''1999-6-2'',没有月份);


并获得28天在第一个和31天中在第二个

结果中。


但是,如果你说1个星期一在这种情况下我总是被认为是30天

我希望收到:


1)1个月 - 2天 (当然,它会返回28天,我知道)

2)1个星期一天


7.1和7.4都没有返回。

您可以提取纪元从间隔中获取间隔中的
秒总数(将月份转换为30天内的秒数),然后将其除以合适的数量。


Are you saying that when PostgreSQL returns "... 3 mons ..."
as a representation of an interval I can safely assume that
when it calculated the number of months it used 30 days
regardless of the actual length of the month ? I couldn''t find
that number mentioned anywhere and had not browsed the source
yet. That would also be contrary to what I thought. I assumed
the following would happen:

select age(''1999-2-2'', ''1999-3-2'');
select age(''1999-5-2'', ''1999-6-2'');

would both return "1 mon" (despite the first one being 28 days
and the second one being 31 days).

I am now looking for a way to say:

select age(''1999-2-2'', ''1999-3-2'', without months);
select age(''1999-5-2'', ''1999-6-2'', without months);

and get "28 days" in the first and "31 days" in the second
result.

However, if you say that "1 mon" is always considered 30 days
in this context I would expect to receive:

1) "1 mon -2 days" (it would return 28 days of course, I know)
2) "1 mon 1 day"

Neither 7.1 nor 7.4 return that.
You can extract "epoch" from the interval to get the total number of
seconds in the interval (converting months to the number of seconds
in 30 days) and then divide that by the appropiate amount.



只有在上述情况适用的情况下才有效,例如月份必须通过计算*生成*间隔

表示固定为30天。在*之后应用epoch *事实并不好,

这样做,因为epoch()代码不知道是否1 mons

是28或29或30或31天。


我在这里遗漏了什么吗?


Karsten

-

GPG钥匙ID E4071346 @ wwwkeys.pgp.net

E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

- -------------------------(播出结束)-------------------- -------

提示1:订阅和取消订阅命令转到 ma **** ***@postgresql.org


That only works if the above holds true, eg the month must be
fixed to 30 days by the calculation *generating* the interval
representation. Applying epoch *after* the fact is no good,
does it, because the epoch() code won''t know whether "1 mons"
is to be 28 or 29 or 30 or 31 days.

Am I missing something here ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


这篇关于可用的间隔输出格式消除歧义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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