Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juHLy-0004Bc-1h for pgsql-general@arkaria.postgresql.org; Sat, 11 Jul 2020 15:23:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1juHLw-0003l5-SF for pgsql-general@arkaria.postgresql.org; Sat, 11 Jul 2020 15:23:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juHLv-0003kr-Bq for pgsql-general@lists.postgresql.org; Sat, 11 Jul 2020 15:23:48 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juHLr-0000Em-Dk for pgsql-general@lists.postgresql.org; Sat, 11 Jul 2020 15:23:46 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 044D8F47; Sat, 11 Jul 2020 11:23:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 11 Jul 2020 11:23:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=n L8PZsii+jz8NtDuG0z/E21lrh3L8NgMroPfb29dv78=; b=SV7VbH+Oc8IAuWO4R +x+lDH4jgSB0PwTXW2h6QzIZoq5IrfbvqaA0KS6PcpCZI98a/Dgp3qlq3wU5ucI5 h7uHaA6gnt6ya4mYc4nusjU+8H5YFqe5LPzsbqHjbojXKUpWSThxm8aiIPlGM6fe fhxgi/RK3ZbSJJyjaZJw4DOOTIAdk05H4jWNoPrVhB0WREaFi4Jr4sKJODQoUgjN iEaouem7OcU2IPqhinVNRr5mQPXsZMkcZa+aAu6F9oSYQXfsSxz6d8Z/msw8YRGY R2d60gaPyPDuNhwy3iGj8aGvZwsA2KKEN+hZW0V8NwDCv4HHQdAuYXyFYQBT8PuL reRDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=nL8PZsii+jz8NtDuG0z/E21lrh3L8NgMroPfb29dv 78=; b=DiAiVpHFMANpZoGpr6tFhkbDI3CtdoVWMcKz/r96qhNZqmhCZkJZMXgig VNtNEHWPrPGK/lggGQnOpQwCCFRrV9DMOd811B8f+OEoWVcmv1UsZ6e5cr/18gre xFoZMlzuvyAIM/Dg2SUcEktOpM96xSNOEfyWBO+l8feB+JuTsmchBFZ1uWpBPddJ GnKA1YIky2WTBajuwAwCODM4/gHYrmQVLzHu4db0DK6fEB4yxZJFb5Zh7J7UH66G NmmnTXPBZBjWSkAuRWx8buPKuwcZB78zog1/tgUAvMK5q0Pu0SfmUNO5zoTqgTyQ NQX2cYc31yO/X8G7qLHEU0SuSkQDg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrvdefgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepveevfeevfeeugeffkeekhfegieeufffgteeujedvgffh ueejjefhkeejleegtdegnecukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id CB3743280060; Sat, 11 Jul 2020 11:23:38 -0400 (EDT) Subject: Re: Issue with timestamp without time zone datatype with default value as now()/localtimestamp To: Deepika S Gowda Cc: pgsql-general@lists.postgresql.org, pgsql-general General References: <5f984784-fde3-9df1-0640-b099e82f13ff@aklaver.com> From: Adrian Klaver Message-ID: <9c5bcc27-f557-1dcd-0994-4b3b39a9300a@aklaver.com> Date: Sat, 11 Jul 2020 08:23:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.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 7/11/20 2:17 AM, Deepika S Gowda wrote: > Hi Adrian, > > System timezone. > [postgres@pvodcdbst0001uk ~]$ timedatectl >       Local time: Fri 2020-07-10 15:44:37 BST >   Universal time: Fri 2020-07-10 14:44:37 UTC >         RTC time: Fri 2020-07-10 14:44:37 >        Time zone: Europe/London (BST, +0100) > > At DB level, > odc=# select now(); >               now > ------------------------------- >  2020-07-10 15:45:20.875835+01 > (1 row) > > odc=# select localtimestamp; >       localtimestamp > --------------------------- >  2020-07-10 15:45:33.28083 > (1 row) > > =============== > Createddate is loaded always with default value. its doesnt pick > anything from source DB wrt this column value. You are going to have to expand on the above. In particular what is the 'source DB'? Does this mean the data is coming from another database? Or more generally where is the data coming from? Bottom line is I don't see DEFAULT now() or localtimestamp randomly reverting back a year. There is something else in this process that is setting the timestamp back. > > As said out of 3k records , sometimes 50 to 100 records it shows as 2019. > > Regards, > Deepika > > > On Fri, Jul 10, 2020 at 7:39 PM Adrian Klaver > wrote: > > On 7/10/20 7:03 AM, Deepika S Gowda wrote: > > Hi, > > > > On postgres 11.7 Master/Slave node, there is column named > "createddate" > > with datatype "timestamp without time zone" with default value as > "now()"; > > > > Column Name | Date Type                 | Default value > > createddate |timestamp without time zone|Now() > > > > > > Issue: From the java application , data is getting loaded into this > > table where we expect column value should be today's date with > > timestamp( "2020-07-10 10:56:43.21"). But, out of 3K records, 100 > > records are loaded as  "2019-07-10 10:56:43.21" (change in Year). > > > > What could be the issue? we tried changing the default value to > > "localtimestamp". > > I would day the choices are: > > 1) A machine has it's clock set wrong. > > 2) The data is being loaded with a value for createdate that overrides > the DEFAULT. > > > > > Kindly help on this request > > > > Regardss, > > Deepika > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com