Android Question Sqlite datetime to MySql data format

Harris

Expert
Licensed User
Longtime User
I store datetime in Sqlite as long. (as is required).
Locally on the device it works great.

When I send this datetime (long) to the server, what type should the MySql table field be?
BigInt (size 20) accepts it, TimeStamp fails, DateTime fails.

If BigInt is the way to go, how do I represent this as a date and time in my web apps?

A bit more than B4a questions, but I am stuck...

Thanks
 

edgar_ortiz

Active Member
Licensed User
Longtime User
Hi,
I store datetime in Sqlite as CHAR, formated YYYY-MM-DD HH:MM:SS

In MySql the field is a DateTime ('2013-09-25 15:16:58')

Regards,

Edgar
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Hi,
I store datetime in Sqlite as CHAR, formated YYYY-MM-DD HH:MM:SS

In MySql the field is a DateTime ('2013-09-25 15:16:58')

Regards,

Edgar


Thanks for the reply.
MySql help states:
  • DATETIME

    A date and time combination. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format, but permits assignment of values to DATETIME columns using either strings or numbers.
The above is a bit confusing.. "using either strings or numbers." What does that mean? I was hoping to use the long to store the datetime in Mysql - yet server returns error (I don't know why - the Job just fails (64 bit long?)).

My SQLite datetime fields (long) can be modified (by milliseconds which I don't see in the string format). Are you suggesting for each record, I also include a CHAR (or just send) to store the same datetime for sending to the server for MySQL?


Thanks
 
Upvote 0
Top