Jump to content


Photo

help with querying database


  • Please log in to reply
1 reply to this topic

#1 k4pil

k4pil
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 08 March 2006 - 12:01 AM

Hi there people.

I have a table called activity in my database as follows;

ID acID time page
1 2 20060307205835 CRM Home
2 2 20060307205838 View customer detail
3 2 20060407205847 Inventory Home Page
4 2 20060407205911 CRM Home
5 2 20060607205916 Inventory Home Page
6 2 20060607212811 View Cases Screen
7 2 20060707212834 Create Case Screen

I want to query this databse from a certain time to a certain time.
I have got the query working;

SELECT * FROM `activity` WHERE time REGEXP '20060307*'

it returns everything starting with that, ignoring the digits after (those represent time so can be ignored).

I want to be able to search from a date e.g 20060307 to 20060707.

Any one have any idea how i can do this??


#2 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 08 March 2006 - 03:53 AM

If theyre numbers,

SELECT *
FROM activity
WHERE time BETWEEN 2006030700000 AND 2006070700000


If theyre dates, then you can use BETWEEN TO_DATE(start) AND TO_DATE(end). etc.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users