0
I have a problem need to filter a query under the following conditions : I have the Data field and I have the time field both in varchar , when I try to make the query like this: ex:
select Serial, Latitude,Longitude,Data,Hora from [CheckPoint]
where Data BETWEEN '20150417' and '20150418'
and Serial= '120904'
and Hora BETWEEN '10:00' and '10:00' order by Hora
the query returns me null; would have any possibility to manipulate these fields into varchar ? If these date and time fields were of type datetime surely would be much simpler query.
Already tried to convert the data?
– Marconi
the date and time field are different columns, they are not in datetime format
– Hans Miller
Is the data always the same size? Ex. Date has 8 digits and Time 5?
– Jean Gustavo Prates
BETWEEN '10:00' and '10:00'
- BETWEEN amid equal hours?– ramaral
@Jeangustavoprates yes. same size!
– Hans Miller
@ramaral between with the two equal values is the same thing to match the desired field. would have a way to make another filter???
– Hans Miller
I only asked because it is not usual to make a BETWEEN between something that has nothing between(BETWEEN). That could be the reason for the query do not return anything. The normal way of doing is
and Hora = '10:00'
– ramaral
It would be easier to help if you put, in the question, an example with half a dozen existing records in the table.
– ramaral
@Hansmiller, you can see physically in the database if this query actually returns records?
– Eudes
If you post the table structure(column data type) and some records you can see if the query is correct. The fact that she returns null, in itself, does not indicate that it is bad, there may be no records that satisfy it.
– ramaral
@Hansmiller can answer ?
– Eudes