pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Deepika S Gowda <deepika.gs@gmail.com>
Cc: pgsql-general@lists.postgresql.org, pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: Issue with timestamp without time zone datatype with default value as now()/localtimestamp
Date: Sat, 11 Jul 2020 08:23:38 -0700
Message-ID: <9c5bcc27-f557-1dcd-0994-4b3b39a9300a@aklaver.com> (raw)
In-Reply-To: <CADaTEeSb6_U57ZcvhOE8++CooeJLs19oeRPaBfEYh4Li+xpcyQ@mail.gmail.com>
References: <CADaTEeShceXK9CFifn3OzYUJQVfGqv3ab4d3fNkDpYvcUp_n3Q@mail.gmail.com>
	<5f984784-fde3-9df1-0640-b099e82f13ff@aklaver.com>
	<CADaTEeSb6_U57ZcvhOE8++CooeJLs19oeRPaBfEYh4Li+xpcyQ@mail.gmail.com>

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 <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> 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 <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (6+ messages)

Message-ID: <9c5bcc27-f557-1dcd-0994-4b3b39a9300a@aklaver.com>
Permalink:  ../9c5bcc27-f557-1dcd-0994-4b3b39a9300a@aklaver.com/
Also on:    postgresql.org/message-id/9c5bcc27-f557-1dcd-0994-4b3b39a9300a@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, deepika.gs@gmail.com
  Subject: Re: Issue with timestamp without time zone datatype with default value as now()/localtimestamp
  In-Reply-To: <9c5bcc27-f557-1dcd-0994-4b3b39a9300a@aklaver.com>
  References: <CADaTEeShceXK9CFifn3OzYUJQVfGqv3ab4d3fNkDpYvcUp_n3Q@mail.gmail.com> <5f984784-fde3-9df1-0640-b099e82f13ff@aklaver.com> <CADaTEeSb6_U57ZcvhOE8++CooeJLs19oeRPaBfEYh4Li+xpcyQ@mail.gmail.com> <9c5bcc27-f557-1dcd-0994-4b3b39a9300a@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