0

AS logcat

Sqlite.sqliteexception:no such column:Timestamp (code1):,while compiling : SELECT * FROM NOTEs ORDER BY Timestamp

I am trying to get the date and time on each entry of note..

Comments
  • 4
    You need a column called "timestamp" which would be bad in itself, you want to make a "created_date" field or similar and populate it on insert that contains the current timestamp or date/time depending on your concerns of the year 2038.

    Also, DONT USE SELECT * !!!!!!!!!!!!!!!!!

    I'll kill you myself if I see prod code that does that.
  • 1
    The timestamp is actually saved for each row (either via a trigger or on the insert query) in a column named Timestamp, right?
  • 2
    @c3r38r170 given the error, I don't think so.

    @Waytopranav, do you have the table schema at hand?
  • 1
    And please. Please.

    Prevent using registered names.

    Never ... Ever ... Use eg. data types as names.

    This can lead to nasty shit.

    https://sqlite.org/lang_keywords.ht...

    SQLite has no timestamp type.

    You'd need an UNSIGNED BIG for that (2038+ compatiblity).

    Please. Always. Really Always. Make sure that you only store UTC values inside a database. It takes away a lot of migraine later.

    And finally: The error generated is very clear. :)
  • 1
    @C0D4 i do. My Sqlite query for table is correct. I will share you once i goto home.
  • 0
    @IntrusionCM i want to get in solve this with your help..
  • 0
    @Waytopranav shouldn't be a problem.

    Post the DDL of the table or the table info...

    Eg by querying sqlite_master:

    @highlight
    select * from sqlite_master where type = 'table';
  • 0
  • 1
    @C0D4 I just tried to make him think about the syntax of the error message.
  • 2
    @c3r38r170 that's fair, but given the error it seems pretty self explan... hold on, ah I see your point.
  • 0
  • 0
  • 0
  • 0
    @C0D4 please help me with this.
  • 1
    @Waytopranav
    Initial issue I see is table name is Notess not Notes as per original post

    I believe "Timestamp" may be being treated as a reserved word so you should enclose these with ' or " depending on if it's a field or a string.

    Something like:

    SELECT field, field2 FROM notes ORDER BY "timestamp" DESC

    Outside of that, without rebuilding and testing I can't see much more that's obvious wrong here.

    On second thought, timestamp isn't in the list for SQLite.

    https://sqlite.org/lang_keywords.ht...
  • 0
    And you don't use Room, because...?
  • 0
    @Xirate could you share the link for any tutorial i can achieve this?
Add Comment