samedi 16 janvier 2016

SQLite difference between datetimes

I've got an SQLite database. In it I've got table X with a column called startDate. I want to make a statement that returns the difference (in DD/MM/YY HH/MM/SS, which is how my startDate column values are formatted) between the datetime(now) and the value in the column.

Problem is, it doesn't return a good value. I've tried understanding the documentation. I think I got it, but it's not returning good values.

Stuff I've tried:

1. strftime('%Y-%m-%d %H:%M:%S', ('now' - startDate))
2. strftime('%Y-%m-%d %H:%M:%S', 'now') - strftime('%Y-%m-%d %H:%M:%S', startDate)
3. datetime('now') - startDate

They return weird values. 1 and 2 tend to return negative values which are not changing as the time lapses. 3 gives me a single value of 2003. The difference between the current date and database values are only a few days.

Aucun commentaire:

Enregistrer un commentaire