2016-07-22 41 views
0

我有一个阅读器表,它具有读取器ID,读取器在(TimeStamp),读出器(TimeStamp)列。我需要根据输入值中的读取器从数据库中提取记录。使用时间戳输入获取数据库记录

我要获取的记录应该与输入中给出的日期相同,并且时间应该等于或小于给定的时间。

Example Values reader in - 26-APR-16 01.37.00.000000000 PM, 25-APR-16 12.11.00.000000000 AM. 

如果输入的日期为26-APR-16下午2点00给出的,我需要为26-APR-16日期与时间等于或更小的提取记录比下午2时00

请帮助我如何通过SQL来实现这一点。

+0

你试过了什么? – Abecee

回答

0
select ... -- enter here which columns you want to select 
from ... -- enter here from which table 
where ... -- this is the clause you need help with. 

where条款是一个有趣的条款。你如何编写它取决于如何给出“输入”。例如,如果给定为绑定变量,我们称之为:input_timestamp,那么where条款可能是:

where reader_in between trunc(:input_timestamp) and :input_timestamp 

trunc在午夜截断时间戳为相同的日期,随着时间的推移00:00:00一天的开始。

相关问题