Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using between with timestamps

Status
Not open for further replies.

jtranex0

Programmer
Jan 15, 2004
3
GB
hello,

iam trying to use a query so it presents all timestamps in the "between" condition using %.

e.g.

timestamps are in format
040206181748

select * from entries where mytimestamp between '04%' and '04%'

hopefully this should print all results for the year 2004, but for the query it returns an empty set, is there anything wrong?

thanks.
 
you must use a

WHERE substring(timestamp_field, 1, 2) = 04

or if you want a range of months

WHERE substring(timestamp_field, 3, 2) >= 04 and
substring(timestamp_field, 3, 2) <= 07

I think you can also use BETWEEN with substring


Bye

QatQat

Life is what happens when you are making other plans.
 
select * from entries where mytimestamp like '04%';

if you are using the same value for both, possibly faster.

otherwise, what QatQat said.


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top