Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1er94Z-0003tG-Qo for pgsql-general@arkaria.postgresql.org; Wed, 28 Feb 2018 21:15:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1er94Y-0005St-P7 for pgsql-general@arkaria.postgresql.org; Wed, 28 Feb 2018 21:15:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1er94Y-0005Sj-Gm for pgsql-general@lists.postgresql.org; Wed, 28 Feb 2018 21:15:34 +0000 Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1er94U-0002Ou-UO for pgsql-general@postgresql.org; Wed, 28 Feb 2018 21:15:33 +0000 Received: by mail-ot0-x236.google.com with SMTP id g97so3581698otg.13 for ; Wed, 28 Feb 2018 13:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgsqlrocket-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=J7lFbvi7Wbyc38s13NDqi6fAj/jLAQIU7hFuCkaIMks=; b=KzlWH4D6SHl0rO/m82u2Va3qpY/AzqVrmazRmuZ7FIzG7/XoRVYK0idk+EXe+1hZeK eIwhMmuhy+T/dX7Um0IYkwTcMjRa11xLnfHeV83cuvGd98CcRefSwDVmzIjf4JFshWqb eFjfF+ZWNhUiGGEBIS+JorEBwrI+XHeA98vc3WjTZkt6zsYfy5sSP0W/feSimddJTUVt 7cNyo0HZNQBqRmNNaQJY7SrQHI3bPJDN4JBiPL7AEHSeTbXPegx0qWtP8JTs3WXowb9/ tEzSeYuJvBXD3RvVE/MySP1I5ivF8zkWhmKa6WshDaLo8XRfudlC+UReVueVQaurmGFJ anaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=J7lFbvi7Wbyc38s13NDqi6fAj/jLAQIU7hFuCkaIMks=; b=YXzvQmE6YgnBbedEy/zmjQkG6jBFXyo7YMnRNTFlypJs7LSUeQw0y9oDSo571Zj/Ya D3CQgevOETNIce0h1ifGdE7NHnVWUhwQ2pHgh2Uk1p6HUj/HTMsfqWidv2ls5yQZfCBa /RJO2sH9g/VOY/I5fRm16sarjswU9tpWVpF9mF2E7DJH5ELz3mLMnNyFXMwkE78guKTS 4p+/YdQin1xVznmQ8kh8ffrw+Y4pnyB1feBzY7urW3L/zWkIqvXCzio9AGl9Ho74t/Kp xj95soGtgljiX3JMOG6D9XROy7Awu10FmOvyziLhPYaglO12rNQYQ0Sa2vJBWHD0yNI/ mcPg== X-Gm-Message-State: APf1xPCVKtiKex+awfof3yDdzhJv11lR1veUrWraqTYEHP2ic0M/OCcq 213qU82CRjpkKsVQcqjzlt/fBAKuQFY= X-Google-Smtp-Source: AG47ELudKTibMzwZVRd05++so2fASHjadXC6ed9W//J0kK+o4sKYP9nms3Lk1QCf38mhHrluWMbe4w== X-Received: by 10.157.26.40 with SMTP id a37mr14695388ote.166.1519852528537; Wed, 28 Feb 2018 13:15:28 -0800 (PST) Received: from localhost.localdomain ([65.132.155.214]) by smtp.gmail.com with ESMTPSA id o36sm1324358otd.25.2018.02.28.13.15.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 13:15:28 -0800 (PST) Subject: Re: selecting timestamp To: "David G. Johnston" Cc: Postgres General References: <0a80c0d7-3c90-3051-3835-8d973db8bdc4@pgsqlrocket.com> <32ecec3a-654d-25e5-75ea-ccd7e2331429@pgsqlrocket.com> From: chris Message-ID: <030374b6-2793-4b7a-970f-929f2050b277@pgsqlrocket.com> Date: Wed, 28 Feb 2018 14:15:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------7062A7502698D0CAA66A14C2" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7062A7502698D0CAA66A14C2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Thank you everyone for the help. Sorry there wasn't much detail given originally. CURRENT_TIMESTAMP at time zone 'UTC' as ct4 Seems to be working well. Thanks, Chris On 02/27/2018 01:26 PM, David G. Johnston wrote: > On Tue, Feb 27, 2018 at 1:16 PM, chris >wrote: > > > What is the best way of selecting current timestamp in UTC? > > > ​You > ​ haven't​ >  define > ​d​ > criteria upon which to judge - and the list below is not exhaustive > ​ (but sufficiently so)​ > ​ > > > SELECT > CURRENT_TIMESTAMP   as ct1 > > > standard conforming, ​assumes server configured for UTC > ​ > > ,timezone('UTC',CURRENT_TIMESTAMP) as ct2 > ,timezone('utc',now()) as ct3 > > > ​non-standard, personally non-obvious (the function looks like an > implementation detail that should be avoided)​ > > ,CURRENT_TIMESTAMP at time zone 'UTC' as ct4 > > > ​This -​ > > standard conforming and doesn't require assumptions about the calling > environment > > ,NOW() at time zone 'utc' as ct5 > > > ​non-standard but frequently used; no semantic different compared to > the previous entry > ​ > David J. > > --------------7062A7502698D0CAA66A14C2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Thank you everyone for the help.
Sorry there wasn't much detail given originally.

CURRENT_TIMESTAMP at time zone 'UTC' as ct4 

Seems to be working well.

Thanks,
Chris

On 02/27/2018 01:26 PM, David G. Johnston wrote:
On Tue, Feb 27, 2018 at 1:16 PM, chris <chrisk@pgsqlrocket.com> wrote:

What is the best way of selecting current timestamp in UTC? 

​You
​ haven't​
 define
​d​
criteria upon which to judge - and the list below is not exhaustive
​ (but sufficiently so)​
​

SELECT
CURRENT_TIMESTAMP   as ct1

standard conforming, ​assumes server configured for UTC
​
 
,timezone('UTC',CURRENT_TIMESTAMP) as ct2
,timezone('utc',now()) as ct3

​non-standard, personally non-obvious (the function looks like an implementation detail that should be avoided)​

,CURRENT_TIMESTAMP at time zone 'UTC' as ct4

​This -​

standard conforming and doesn't require assumptions about the calling environment

,NOW() at time zone 'utc' as ct5

​non-standard but frequently used; no semantic different compared to the previous entry
​
David J.



--------------7062A7502698D0CAA66A14C2--