Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eN08s-0000Y3-I1 for pgsql-sql@arkaria.postgresql.org; Thu, 07 Dec 2017 17:39:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eN08s-0001ZP-3B for pgsql-sql@arkaria.postgresql.org; Thu, 07 Dec 2017 17:39:26 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eMzxt-0007fb-Tc for pgsql-sql@lists.postgresql.org; Thu, 07 Dec 2017 17:28:06 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eMzxr-0000y7-6e for pgsql-sql@lists.postgresql.org; Thu, 07 Dec 2017 17:28:04 +0000 Received: by mail-wm0-x22e.google.com with SMTP id g130so1536731wme.0 for ; Thu, 07 Dec 2017 09:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:newsgroups:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=13bRWE04baPw3TYffTEsooa//vvWBlTjRnUGl0O4DiM=; b=XG6YzefEMCl/6YqiI0D5h7Rui9HGrOV9zf+C8wWB4/u0cPcsQGAI95+9f6+bkW5rxD s4qCRw1igTivE3IyfOKJRsncVk4PvwqTPUD60P5N/wfx+75q8bt1+d9jDNZfpcWOEWNU 2OJW6QjALXB3SDpfns80eNS300DtpsTDl9i/s1hjQkga5w029Z24iTcR+oTX6D+MQ4hV bzbgFaX6MCwj2wcyrFMJwTw5JM66e93w4SCtZzqIT+HMlKYk+mM6nsMQY3bGCCjSGUl3 S5pSycbTGnrEAb/eF4J/OucRmM/+21bJETDSqLrJ66KAk4Bhw0IY6sC0r17DeiG1Rzca KPqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:newsgroups:references:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=13bRWE04baPw3TYffTEsooa//vvWBlTjRnUGl0O4DiM=; b=WP7sn6vtgX+uiiyah6y3I5BOflNIfC+wUnWxpPTYhj57SzIXtHzxNafny7OkJJvAIf IBGHfxnwmZ2AALTv+TKF/smMALHl7KXoAJ7FY6eteI9ZWzByh7hlUl9e/G6f/Yz51RWc ugy6WyBER6qgVelroy3pcbvWBNCUSwgO6S1hk1vDVbN4OqhdZLarupCPyc7Yc5wXc8jb YhehTrS6MG63tf+PH7171+skeLRnrR6w3teUny/mYUYMb885V2QhGJ3m5rHTBm6AatI7 vD+q4+vEJew1vwS0ZRQXO6b8WLh/XihNTneoLaCV3hjv06M9CgvrxmqJ/qiy+3w45tde Zq2Q== X-Gm-Message-State: AJaThX5b9nZ9fOLHU4dxU1jZYfQrS7OMZARicuKN8YxZ6ON/u8zADY5t NLy7dsAJN09yBzSB9dL/LKqO7z0B X-Google-Smtp-Source: AGs4zMbdSKLS/Sc82KdMgjQZnqlgSvpYZelBqGcoKrPPhVG4Kk/J/UusbHtJplfb0IYd6LVq4N+ZzQ== X-Received: by 10.80.157.134 with SMTP id w6mr48181922ede.151.1512667681066; Thu, 07 Dec 2017 09:28:01 -0800 (PST) Received: from ?IPv6:2001:980:9089:1:b856:368b:43ef:84b1? ([2001:980:9089:1:b856:368b:43ef:84b1]) by smtp.gmail.com with ESMTPSA id e49sm2758735eda.90.2017.12.07.09.27.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 09:27:58 -0800 (PST) From: Luuk X-Google-Original-From: Luuk Subject: Re: Timestamp alculation identical to Microsoft Excel results To: pgsql-sql@lists.postgresql.org Newsgroups: lists.pgsql.sql References: Message-ID: <20758a7c-051b-276f-3c9b-e106ab3f15ad@invalid.lan> Date: Thu, 7 Dec 2017 18:27:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07-12-17 10:59, Ertan Küçükoğlu wrote: > Hello, > > There is this Excel report which will be produced by an application. In > Excel, there is below equation > 31/10/2017 15:05 - 31/10/2017 14:36:00 = 0:28:21 > 2017-10-31 13:22:17 - 2017-11-01 14:47:45 = 1/1/1900 01:25 > > That is very simple in PostgreSQL. Simply subtract two timestamp without > time zone fields and you have the result. However, Excel also represent that > result 0:28:21 as double notation 0.0196874999965075 and 1/1/1900 01:25 as > 1,05935185185081. > > I could not see any way to have same values using PostgreSQL query. I tried: > extract(epoch from time_field2) - extract(epoch from time_field1) and result > is 1701 and 5128 respectively. > > Putting aside reasons as to why numbers are used instead of more human > understandable time format, I would like to learn if having same results as > Excel is possible. > > Thanks & regards, > Ertan Küçükoğlu > This is what the maker of excel has to say about that: https://support.microsoft.com/en-us/help/214094/how-to-use-dates-and-times-in-excel