Does the timestamp type have (hidden) milliseconds?



  • The updated column was created as

    | updated | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
    

    a simple SELECT gives

    +---------------------+
    | updated             |
    +---------------------+
    | 2021-12-25 00:15:47 |
    +---------------------+
    

    Unfortunately, updated was not created as timestamp(3).

    Is there any way to extract more accuracy from updated? (does MySQL store more precision than the second, even though it shows only seconds?)



  • Is there any way to extract more accuracy from updated?

    No. It is not possible to select the data which is absent in the table and cannot be calculated from the data present in the tables.

    does MySQL store more precision than the second, even though it shows only seconds?

    No. It stores exactly what you asked for. It can store up to microsecond - but you have not asked for this accuracy.

    Well, it really is déjà vu all over again with this question! There appears to be a bug in MySQL's implementation of this... (quelle suprise - a bug in MySQL...) at least on dbfiddle.uk and dbfiddle.com. – Vérace - get VACCINATED NOW

    You call NOW() - and you get the datetime without milliseconds. Call NOW(3) or NOW(6) and get more accurate value.

    https://dbfiddle.uk/?rdbms=mysql_5.7&fiddle=ccaf9b2c25e372c7bf0ca82c66ded787

    Well, good news from the MySQL camp - you don't need to worry about fractional values of a second at all - 5.7 doesn't support them – Vérace - get VACCINATED NOW

    Never consult the person from the MySQL camp who said this nonsense again.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2