Android Question sqlite timestamp / android system time

merlin2049er

Well-Known Member
Licensed User
Longtime User
I've got to log some data in a sqlite table. I'm using a timestamp field in the table.

I'm reading values from a low energy bluetooth device, and updating a display. Just wondering if the android date.now / time.now is the equivalent to the timestamp (current timestamp).

Or should write the timestamp to the record, then read the timestamp and update the display after inserting a record.
 

sorex

Expert
Licensed User
Longtime User
now covers date and time.

current_timestamp can also be used in sqlite & mysql
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
if you have doubt you could just set the default value for that field to current_timestamp.

then you just need to insert the value, it will add the timestamp in the right format for you.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
Just create the field in the SQLite Database with these properties:

B4X:
  MyTimeStamp DATETIME DEFAULT CURRENT_TIMESTAMP


And then, when you add a new record, the SQLite engine will add the time stamp automatically
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…