Gabrielle
Gabrielle

Reputation: 4981

Compare datetime in android sqlite

I have this statement :

SELECT t1.* FROM pos t1
        INNER JOIN pos_visit t2
           ON t2.pos_id = t1.id_pos
        INNER JOIN roadmap t3
           ON t3.id_roadmap = t2.roadmap_id
WHERE t3.id_roadmap ='rmp100000000000000020121206114347690'
    AND datetime(t1.lastChangedDate) > datetime(t3.lastChangedDate);

and I get no such a function datetime.

I mention that I tried strftime too. All this functions works fine on sqLiteBrowser, but in Android, it is not working. I tried julianday and I don't get any error, but the Select is not returning the correct values (it should return one registration and it does not return anything)

Any idea where is the problem ?

Upvotes: 0

Views: 1597

Answers (1)

nano_nano
nano_nano

Reputation: 12523

you can solve the problem this way:

I store datetimes as YYYYMMDDHH. so I can execute stempel >= '2012120612' and stempel <= '2012122412'

Another trick is to save the date as long values(lDate.getTime() in java). so you can do this:

stempel >= 1231243154123123 and stempel <= 1231234235526265

Upvotes: 1

Related Questions