>>If you do not have the index on this field, then you may use locate command, like:
>>
>>locate for between(...)
>>*or
>>locate for datetime>... and datetime <...
>>
>
>This will not gonna work properly, because it will not necessarilly find the one that is closest to the given datetime.
Sure not. I said, "like" and I did not provide the exact solution. Seek will also not work properly because it will stop the NEXT closest match. So it will not work if the PREVIOUS is more closer.
The exact solution requires either preliminary calculation of the exact closest datetime, or manipulating with the ascending/descending order when setting near on.
>
>
>>Otherwise:
>>
>>set order to ...
>>set near on
>>?seek(...)
>>
>>
>>
>>>Hi,
>>>I'd like to find a datetime field in a table which is the nearest to a certain given datetime. What functions can be used? And Any idea would be appreciated.
>>>
>>
>>>Thanks
>>>
>>>Tamas Szigeti