samedi 11 juillet 2015

TimeStamp Difference Between Java and SQLite

Hello I have and SLQLite database in which I store date in milliseconds. e.g

Calendar cal = Calendar.getInstance(); 
cal.getTimeInMillis();

My SQLite datefield is integer. My problem is I want to get the day from the my date column however java calendar timestamp is different from one in SLQLite

1436859563832 --> result from cal.getTimeInMillis();

1436607407--> SELECT strftime('%s','now')

What I'm trying to do is to group records by day. The following SQL query works just fine if value of SELECT strftime('%s','now') is paste in the date column

SELECT SUM(amount), date(`date`) FROM water_logs
GROUP BY date(`date`)

Aucun commentaire:

Enregistrer un commentaire