Karthick V - TLS , Chennai <[EMAIL PROTECTED]>
wrote:
I need to get the row id for a time which falls within the start and
end
time.

I am using this query.

select RowID,
strftime('%Y-%m-%dT%H:%M:%S',starttime),
strftime('%Y-%m-%dT%H:%M',endtime) from History where
strftime('%Y-%m-%dT%H:%M',starttime) <
strftime('%Y-%m-%dT%H:%M','2006-11-17T12:17') and
strftime('%Y-%m-%dT%H:%M',endtime) >
strftime('%Y-%m-%dT%H:%M','2006-11-17T12:17');

This works well if there is only one matching row.

However if more than one row matches, I need to get the row whose
start time
is closest to the given time.

Just add

order by strftime('...', starttime) desc limit 1;

Observe that, since all starttimes are before the given time, the nearest one is also the latest one.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to