pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Abraham, Danny <danny_abraham@bmc.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: day interval
Date: Sat, 12 Oct 2019 10:39:31 -0700
Message-ID: <565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com> (raw)
In-Reply-To: <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com>
References: <a95dd36dcc5d4e7380550a727716cfe0@phx-exmbprd-01.adprod.bmc.com>
	<8736fyxa2a.fsf@news-spur.riddles.org.uk>
	<e8d3c7014a2d43f4b1cfe780d61ccde5@phx-exmbprd-01.adprod.bmc.com>
	<279cfb68-22c7-c5c6-95ec-8234831faf38@aklaver.com>
	<0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com>

On 10/12/19 9:34 AM, Abraham, Danny wrote:
> The problematic code is:
> select date(cm_curr_date) - date(CM_DATE) into diff_days from CMS_SYSPRM;
> 
> 
> The fix is:
> select date_part ('day', age( date(cm_curr_date), date(CM_DATE))) into diff_days from CMS_SYSPRM;
> 
> The problem:
> How to recreate the problem.  (You know - QA).

Upstream you said:

"This has been working for years on all PG community servers.

This happens on an EDB PG 9.6.3."

Which version of the EDB Postgres database are you using e.g. their 
install of the community version or their modified(Advanced?) version?

When I search on CMS_SYSPRM it comes related to bmc.com, is that in the 
mix also?


> 
> Tried changing lc_time, timezone and datestyle .. but nothing seems to work
> 
> Thanks
> 
> Danny
> 
> -----Original Message-----
> From: Adrian Klaver <adrian.klaver@aklaver.com>
> Sent: Saturday, October 12, 2019 7:27 PM
> To: Abraham, Danny <danny_abraham@bmc.com>; Andrew Gierth <andrew@tao11.riddles.org.uk>
> Cc: pgsql-general@postgresql.org
> Subject: [EXTERNAL] Re: day interval
> 
> On 10/12/19 8:37 AM, Abraham, Danny wrote:
>> Thanks Andrew.
>>
>> My code fails since the expression (In a PG/PG SQL function) which
>> assumes integer result Now produces the string '8 day';
> 
> The code is?
> 
>>
>> This has been working for years on all PG community servers.
>>
>> This happens on an EDB PG 9.6.3.
>>
>> I know the fix, but I need the ability to create the bug in my server, and I do not know how.
>>
>> Thanks
>>
>> Danny
>>
>>
>> -----Original Message-----
>> From: Andrew Gierth <andrew@tao11.riddles.org.uk>
>> Sent: Saturday, October 12, 2019 6:26 PM
>> To: Abraham, Danny <danny_abraham@bmc.com>
>> Cc: pgsql-general@postgresql.org
>> Subject: [EXTERNAL] Re: day interval
>>
>>>>>>> "Abraham" == Abraham, Danny <danny_abraham@bmc.com> writes:
>>
>>    Abraham> Hi
>>    Abraham> A question on day interval
>>
>>    Abraham> select date('20191001') - date('20190923');
>>
>>    Abraham> Will provide sometimes '8' - an integer , but sometimes '8
>> Abraham> day' - a string
>>
>> No, it'll always return an integer. You will only get an interval result if you subtract timestamps rather than dates, for example if one of the operands is actually an expression returning a timestamp.
>>
>> Give an example of an actual expression you used that returned an interval instead, and we may be able to tell you how to fix it.
>>
>> --
>> Andrew (irc:RhodiumToad)
>>
>>
>>
> 
> 
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (13+ messages)  latest in thread

Message-ID: <565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com>
Permalink:  ../565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com/
Also on:    postgresql.org/message-id/565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, danny_abraham@bmc.com
  Subject: Re: day interval
  In-Reply-To: <565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com>
  References: <a95dd36dcc5d4e7380550a727716cfe0@phx-exmbprd-01.adprod.bmc.com> <8736fyxa2a.fsf@news-spur.riddles.org.uk> <e8d3c7014a2d43f4b1cfe780d61ccde5@phx-exmbprd-01.adprod.bmc.com> <279cfb68-22c7-c5c6-95ec-8234831faf38@aklaver.com> <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> <565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox