Postgres timestamp field not showing microseconds component when value is all zeros2019 Community Moderator ElectionPostgreSQL: Select where timestamp is emptyUsing variables in SQLPSQL slower than PgAdmin IIIMake PostgreSQL timestamps display milliseconds even if zeroPostgreSQL JDBC Driver rounds crops double valuetrying to automatically timestamp postgresql table, ERROR: record “new” is not assigned yetpostgresql - losing command prompt after select from quoted table namePostgres insert adds empty values as ' ' - how to show blank insteadcopy timestamp value from one table to other table in postgresJOOQ timestamp field default value different from the db default value

What is the adequate fee for a reveal operation?

Welcoming 2019 Pi day: How to draw the letter π?

Why does a Star of David appear at a rally with Francisco Franco?

What is the significance behind "40 days" that often appears in the Bible?

What is the Japanese sound word for the clinking of money?

Why does overlay work only on the first tcolorbox?

A diagram about partial derivatives of f(x,y)

I am confused as to how the inverse of a certain function is found.

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

Professor being mistaken for a grad student

The German vowel “a” changes to the English “i”

Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?

"of which" is correct here?

Instead of a Universal Basic Income program, why not implement a "Universal Basic Needs" program?

Is there a symmetric-key algorithm which we can use for creating a signature?

Are ETF trackers fundamentally better than individual stocks?

How could an airship be repaired midflight?

How could a scammer know the apps on my phone / iTunes account?

Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)

Violin - Can double stops be played when the strings are not next to each other?

Bacteria contamination inside a thermos bottle

Brexit - No Deal Rejection

My adviser wants to be the first author

What is "focus distance lower/upper" and how is it different from depth of field?



Postgres timestamp field not showing microseconds component when value is all zeros



2019 Community Moderator ElectionPostgreSQL: Select where timestamp is emptyUsing variables in SQLPSQL slower than PgAdmin IIIMake PostgreSQL timestamps display milliseconds even if zeroPostgreSQL JDBC Driver rounds crops double valuetrying to automatically timestamp postgresql table, ERROR: record “new” is not assigned yetpostgresql - losing command prompt after select from quoted table namePostgres insert adds empty values as ' ' - how to show blank insteadcopy timestamp value from one table to other table in postgresJOOQ timestamp field default value different from the db default value










0















Context: I'm using Postgres 9.3 and psql (PostgreSQL) 11.1.



Given the following table:



create table ts_test(ts timestamp);


The following insert commands display time with microsecond granularity:



INSERT INTO ts_test
VALUES
(now()),
(TIMESTAMP '2019-03-06 20:18:41.000001');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001


However, when a timestamp with all zeroes as the microsecond component is inserted, I observe the following behavior:



INSERT INTO ts_test VALUES (TIMESTAMP '2019-03-06 20:18:41.000000');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001
2019-03-06 20:18:41


I've pored over the documentation, but am drawing a total blank as to why the microseconds are omitted from the third entry.










share|improve this question
























  • I'm using psql (PostgreSQL) 11.1

    – Mr. S
    Mar 6 at 20:47












  • Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

    – Erwin Brandstetter
    Mar 7 at 1:06















0















Context: I'm using Postgres 9.3 and psql (PostgreSQL) 11.1.



Given the following table:



create table ts_test(ts timestamp);


The following insert commands display time with microsecond granularity:



INSERT INTO ts_test
VALUES
(now()),
(TIMESTAMP '2019-03-06 20:18:41.000001');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001


However, when a timestamp with all zeroes as the microsecond component is inserted, I observe the following behavior:



INSERT INTO ts_test VALUES (TIMESTAMP '2019-03-06 20:18:41.000000');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001
2019-03-06 20:18:41


I've pored over the documentation, but am drawing a total blank as to why the microseconds are omitted from the third entry.










share|improve this question
























  • I'm using psql (PostgreSQL) 11.1

    – Mr. S
    Mar 6 at 20:47












  • Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

    – Erwin Brandstetter
    Mar 7 at 1:06













0












0








0








Context: I'm using Postgres 9.3 and psql (PostgreSQL) 11.1.



Given the following table:



create table ts_test(ts timestamp);


The following insert commands display time with microsecond granularity:



INSERT INTO ts_test
VALUES
(now()),
(TIMESTAMP '2019-03-06 20:18:41.000001');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001


However, when a timestamp with all zeroes as the microsecond component is inserted, I observe the following behavior:



INSERT INTO ts_test VALUES (TIMESTAMP '2019-03-06 20:18:41.000000');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001
2019-03-06 20:18:41


I've pored over the documentation, but am drawing a total blank as to why the microseconds are omitted from the third entry.










share|improve this question
















Context: I'm using Postgres 9.3 and psql (PostgreSQL) 11.1.



Given the following table:



create table ts_test(ts timestamp);


The following insert commands display time with microsecond granularity:



INSERT INTO ts_test
VALUES
(now()),
(TIMESTAMP '2019-03-06 20:18:41.000001');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001


However, when a timestamp with all zeroes as the microsecond component is inserted, I observe the following behavior:



INSERT INTO ts_test VALUES (TIMESTAMP '2019-03-06 20:18:41.000000');


select * from ts_test;
ts
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001
2019-03-06 20:18:41


I've pored over the documentation, but am drawing a total blank as to why the microseconds are omitted from the third entry.







postgresql psql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 21:37









a_horse_with_no_name

303k46465561




303k46465561










asked Mar 6 at 20:45









Mr. SMr. S

8801822




8801822












  • I'm using psql (PostgreSQL) 11.1

    – Mr. S
    Mar 6 at 20:47












  • Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

    – Erwin Brandstetter
    Mar 7 at 1:06

















  • I'm using psql (PostgreSQL) 11.1

    – Mr. S
    Mar 6 at 20:47












  • Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

    – Erwin Brandstetter
    Mar 7 at 1:06
















I'm using psql (PostgreSQL) 11.1

– Mr. S
Mar 6 at 20:47






I'm using psql (PostgreSQL) 11.1

– Mr. S
Mar 6 at 20:47














Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

– Erwin Brandstetter
Mar 7 at 1:06





Aside, Postgres 9.3 reached EOL in November 2018. Consider upgrading: postgresql.org/support/versioning psql is only the command-line terminal.

– Erwin Brandstetter
Mar 7 at 1:06












1 Answer
1






active

oldest

votes


















0














TIMESTAMP '2019-03-06 20:18:41.000000' and TIMESTAMP '2019-03-06 20:18:41' are identical values. All-zero fractional digits, that's just insignificant noise which is not stored in the data type timestamp (internally an 8-byte integer).



If you want to preserve original literals including all noise, insignificant zeros and white space, you'll have to store it in a string type like text.



If you want to display timestamps with microseconds you might use to_char() with the template pattern US:



select to_char(ts, 'YYYY-MM-DD HH24:MI:SS:US') AS ts1 from ts_test;
ts1
----------------------------
2019-03-06 20:40:35.062547
2019-03-06 20:18:41.000001
2019-03-06 20:18:41.000000 -- !


This result is text, of course. (Use the pattern MS for milliseconds.)






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031871%2fpostgres-timestamp-field-not-showing-microseconds-component-when-value-is-all-ze%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    TIMESTAMP '2019-03-06 20:18:41.000000' and TIMESTAMP '2019-03-06 20:18:41' are identical values. All-zero fractional digits, that's just insignificant noise which is not stored in the data type timestamp (internally an 8-byte integer).



    If you want to preserve original literals including all noise, insignificant zeros and white space, you'll have to store it in a string type like text.



    If you want to display timestamps with microseconds you might use to_char() with the template pattern US:



    select to_char(ts, 'YYYY-MM-DD HH24:MI:SS:US') AS ts1 from ts_test;
    ts1
    ----------------------------
    2019-03-06 20:40:35.062547
    2019-03-06 20:18:41.000001
    2019-03-06 20:18:41.000000 -- !


    This result is text, of course. (Use the pattern MS for milliseconds.)






    share|improve this answer



























      0














      TIMESTAMP '2019-03-06 20:18:41.000000' and TIMESTAMP '2019-03-06 20:18:41' are identical values. All-zero fractional digits, that's just insignificant noise which is not stored in the data type timestamp (internally an 8-byte integer).



      If you want to preserve original literals including all noise, insignificant zeros and white space, you'll have to store it in a string type like text.



      If you want to display timestamps with microseconds you might use to_char() with the template pattern US:



      select to_char(ts, 'YYYY-MM-DD HH24:MI:SS:US') AS ts1 from ts_test;
      ts1
      ----------------------------
      2019-03-06 20:40:35.062547
      2019-03-06 20:18:41.000001
      2019-03-06 20:18:41.000000 -- !


      This result is text, of course. (Use the pattern MS for milliseconds.)






      share|improve this answer

























        0












        0








        0







        TIMESTAMP '2019-03-06 20:18:41.000000' and TIMESTAMP '2019-03-06 20:18:41' are identical values. All-zero fractional digits, that's just insignificant noise which is not stored in the data type timestamp (internally an 8-byte integer).



        If you want to preserve original literals including all noise, insignificant zeros and white space, you'll have to store it in a string type like text.



        If you want to display timestamps with microseconds you might use to_char() with the template pattern US:



        select to_char(ts, 'YYYY-MM-DD HH24:MI:SS:US') AS ts1 from ts_test;
        ts1
        ----------------------------
        2019-03-06 20:40:35.062547
        2019-03-06 20:18:41.000001
        2019-03-06 20:18:41.000000 -- !


        This result is text, of course. (Use the pattern MS for milliseconds.)






        share|improve this answer













        TIMESTAMP '2019-03-06 20:18:41.000000' and TIMESTAMP '2019-03-06 20:18:41' are identical values. All-zero fractional digits, that's just insignificant noise which is not stored in the data type timestamp (internally an 8-byte integer).



        If you want to preserve original literals including all noise, insignificant zeros and white space, you'll have to store it in a string type like text.



        If you want to display timestamps with microseconds you might use to_char() with the template pattern US:



        select to_char(ts, 'YYYY-MM-DD HH24:MI:SS:US') AS ts1 from ts_test;
        ts1
        ----------------------------
        2019-03-06 20:40:35.062547
        2019-03-06 20:18:41.000001
        2019-03-06 20:18:41.000000 -- !


        This result is text, of course. (Use the pattern MS for milliseconds.)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 1:03









        Erwin BrandstetterErwin Brandstetter

        351k68640819




        351k68640819





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031871%2fpostgres-timestamp-field-not-showing-microseconds-component-when-value-is-all-ze%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved