mercredi 21 octobre 2015

Getting data according to last hours from sqlite

I want to get records out of sqlite database according to hours. following are my questions

1) I have to extract all data from sqlite for past one hour. I have tried following query but it provide me data for all the hours in present day

Query:

SELECT * FROM Table1 where Date >= datetime('now','-1 hours') Where Table1 is my table name and Date is coloumn name of type DATETIME

Eg: there are following record in database

enter image description here

When I fire query in sqlite firefox browser tool it returns me

enter image description here

which I do not want.

What should be the query to get past 1 hour data from database

2) What should be query to get the value out of database according to every hours, like I have to get data for past 1 hour, then data of past 1-2 hour, the data of past 2-3 hour i.e an hour data between two hours?

Any Help will be appreciated.

Aucun commentaire:

Enregistrer un commentaire