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 1juEfc-0007fA-V3 for pgsql-general@arkaria.postgresql.org; Sat, 11 Jul 2020 12:31:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1juEfZ-0005pl-JE for pgsql-general@arkaria.postgresql.org; Sat, 11 Jul 2020 12:31:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juEfZ-0005kV-3c for pgsql-general@lists.postgresql.org; Sat, 11 Jul 2020 12:31:53 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1juEfW-0003Ef-MO for pgsql-general@postgresql.org; Sat, 11 Jul 2020 12:31:52 +0000 Received: by mail-pg1-x544.google.com with SMTP id o13so3770157pgf.0 for ; Sat, 11 Jul 2020 05:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=eRChSl4+B9+sCWOahKHYqS8ISfWTkD8SDfS2WvMX2eI=; b=JXVXlC9cLD4p+i4ls3wK8NDrZjgmCJ5iYKHvFMKGi9tAyKlWBq1q54N4tvW4BRQWxz BBIBzbwbqipxly6ZPtzAtMRkYAn7l9Hiy89F9mT7B/vTn2QNPDbmAWtE0GszvfKZuWVx QIR068cx9Fb06yrCETnoJ3bzSDJRje4UJquZberp3LN3oUvD91dZSndXLGm/+trou+Ic FuXuSGLszfKJRmPPgrP9/B1NebXQFo5puaYsbZ5G766c8vO2WL7nqamrj8wTqDC7x5p8 pK+7X2zxnh5MdsHMsgVuB3VhHwSTSgnR6L/X3Wpu+LKkJT6rpLu4uNFAAxv6H3jvhfUy X9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=eRChSl4+B9+sCWOahKHYqS8ISfWTkD8SDfS2WvMX2eI=; b=mv0y+Y7dMYug5FaRcPBA47tCUqy1O+hCvmnyf7PvBGXGk0IsPvsi0B3DArt/msmYOG 0grN5HfNOPD7l3q1Be1hij6v8xnOUcCdGPQnXlU8ztdn29fFFJZGM3eVBx+cxx2s5OXt qvr/GuSYQstjfZXgUH4SvSe67hPVrRXIAy79UWHwpMIaDJcX0j+VlWhx0toq5obFePe7 fc7zQ180RRgqmX3DKd9apk+wolElsCYRLrSrcTvujR8V0zjO7xZitOgTc26QiX6j8/Dq eH4Tcc/aNnJ5gg/SAZhuSUk3NDHTGbmHxKIal6yxz+c2mdQ3AMorn5BwZgVLnWGaRlxm +uew== X-Gm-Message-State: AOAM532nZf0AV02hXl5M4m/mtV2IRpNQzT5asNqz8KHd9H9BpZyDf+nG refhtVE91z8Te46dLLhilxo= X-Google-Smtp-Source: ABdhPJzDUsprmk7yWFd/kkuuLGk44b+a/l2463x4dlEfc7rLpTEcZaI+96E6p/QJKAA38Zw2CseTFw== X-Received: by 2002:a62:6d03:: with SMTP id i3mr60753805pfc.6.1594470709544; Sat, 11 Jul 2020 05:31:49 -0700 (PDT) Received: from ?IPv6:2601:681:5500:dde0:b16b:27af:b510:d29d? ([2601:681:5500:dde0:b16b:27af:b510:d29d]) by smtp.gmail.com with ESMTPSA id e195sm8670767pfh.218.2020.07.11.05.31.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Jul 2020 05:31:49 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-754F5EE6-1F37-4459-BEDB-B47CC860D4D6 Content-Transfer-Encoding: 7bit From: Rob Sargent Mime-Version: 1.0 (1.0) Subject: Re: Issue with timestamp without time zone datatype with default value as now()/localtimestamp Date: Sat, 11 Jul 2020 06:31:47 -0600 Message-Id: <4E53AAF2-4117-4249-A98E-56412E083BC3@gmail.com> References: Cc: Adrian Klaver , pgsql-general@lists.postgresql.org, pgsql-general General In-Reply-To: To: Deepika S Gowda X-Mailer: iPhone Mail (17F80) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-754F5EE6-1F37-4459-BEDB-B47CC860D4D6 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Jul 11, 2020, at 3:17 AM, Deepika S Gowda wrote:= >=20 > =EF=BB=BF > Hi Adrian, >=20 > 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) >=20 > At DB level, > odc=3D# select now(); > now > ------------------------------- > 2020-07-10 15:45:20.875835+01 > (1 row) >=20 > odc=3D# select localtimestamp; > localtimestamp > --------------------------- > 2020-07-10 15:45:33.28083 > (1 row) >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Createddate is loaded always with default value. its doesnt pick anything f= rom source DB wrt this column value. >=20 > As said out of 3k records , sometimes 50 to 100 records it shows as 2019. >=20 > Regards, > Deepika >=20 >=20 >> On Fri, Jul 10, 2020 at 7:39 PM Adrian Klaver = wrote: >> On 7/10/20 7:03 AM, Deepika S Gowda wrote: >> > Hi, >> >=20 >> > On postgres 11.7 Master/Slave node, there is column named "createddate"= =20 >> > with datatype "timestamp without time zone" with default value as "now(= )"; >> >=20 >> > Column Name | Date Type | Default value >> > createddate |timestamp without time zone|Now() >> >=20 >> >=20 >> > Issue: =46rom the java application , data is getting loaded into this=20= >> > table where we expect column value should be today's date with=20 >> > timestamp( "2020-07-10 10:56:43.21"). But, out of 3K records, 100=20 >> > records are loaded as "2019-07-10 10:56:43.21" (change in Year). >> >=20 >> > What could be the issue? we tried changing the default value to=20 >> > "localtimestamp". >>=20 >> I would day the choices are: >>=20 >> 1) A machine has it's clock set wrong. >>=20 >> 2) The data is being loaded with a value for createdate that overrides=20= >> the DEFAULT. >>=20 >> >=20 You=E2=80=99ll have to show the code generating the records. And the insert.= =20 Your first post had times identical to the sub-second. We=E2=80=99re those a= rtificial values? If so, can you show actual selected values which you belie= ve arrived at approximately the same time but have both years? Include the s= ql.=20 --Apple-Mail-754F5EE6-1F37-4459-BEDB-B47CC860D4D6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Jul 11, 2020, at 3:17 AM, Deepika S Gowda &= lt;deepika.gs@gmail.com> wrote:

=EF=BB=BF
Hi Adrian,

System timezone.
[postgres@pvodcdbst0001uk ~]$ timedatectl=
      Local time: Fri 2020-07-10 15:44:37 BST
  U= niversal time: Fri 2020-07-10 14:44:37 UTC
        RT= C time: Fri 2020-07-10 14:44:37
       Time zone: Eur= ope/London (BST, +0100)

At DB level,
= odc=3D# select now();
              no= w
-------------------------------
 2020-07-10 15:45:20.875835+01<= br>(1 row)

odc=3D# select localtimestamp;
      loc= altimestamp
---------------------------
 2020-07-10 15:45:33.2808= 3
(1 row)

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
Createddate is loaded always with default value. its doe= snt pick anything from source DB wrt this column value.

=
As said out of 3k records , sometimes 50 to 100 records it shows as 201= 9.

Regards,
Deepika


On Fri, Jul 10, 2020 at 7:39 PM Adrian Klaver <adrian.klaver@aklaver.com> wro= te:
On 7/10/20 7:0= 3 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: =46rom the java application , data is getting loaded into this <= br> > 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).<= br> >
> 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.

>
You=E2=80=99ll have to show t= he code generating the records. And the insert. 
Your first post ha= d times identical to the sub-second. We=E2=80=99re those artificial values? I= f so, can you show actual selected values which you believe arrived at appro= ximately the same time but have both years?  Include the sql. 
=

= --Apple-Mail-754F5EE6-1F37-4459-BEDB-B47CC860D4D6--