jeudi 5 novembre 2015

sqlite select date from datetime row

Hi I have a table that have a datetime column like: '2015/01/10 09:58:03' Is posible select specifying only the date? I've tried this but no results:

SELECT datetime, value FROM lectures WHERE datetime=DATE('2015/01/10')
SELECT datetime, value FROM lectures WHERE datetime=DATE('2015-01-10')
SELECT datetime, value FROM lectures WHERE datetime='20150110'

I Can obtain the required result (values from one day) with this query but no seems too elegant:

SELECT datetime, valor_lectura FROM lectures WHERE datetime>'2015/01/10' and datetime<'2015/01/11'

Other question: Whats the best method to obtain only the first record or only the last record of the results of a query? At the moment can obtain these sending all results to a table (with language php or python) and obtain the record with table functions.

Thanks!!!!

Aucun commentaire:

Enregistrer un commentaire