Jump to content

Range of dates?


techiefreak05

Recommended Posts

I am building an analytics service, and whenever a page is loaded, it inserts a row into the database with tons of user information. Simple enough.

 

Each row has a DATETIME field (ex, "2010-09-30 11:53:14") and after a while I've been able to count the number of unique visits, and total visits for a particular day. Here's the query that will run for EACH day:

 

SELECT COUNT(DISTINCT(ip)) as unique_hits,
COUNT(ip) as total_hits,
date as raw_date 
FROM tracking
WHERE
date_format(date,'%Y-%m-%d') = '2010-09-30'

 

Basically I want to be able to pick 2 dates from a form, and then loop through each day between them, and run the query above for each day.

 

I hope I made sense... haha.

 

Thanks a ton.

 

Link to comment
Share on other sites

After some tweaking, I got it. You were correct, it worked as needed.

 

I ended up with this, in case you're curious:

 

SELECT DISTINCT date_format(date,'%Y-%m-%d') as xdate FROM `tracking` 
WHERE owner_id = '18' AND 
project_id = '1' AND 
date_format(date,'%Y-%m-%d') BETWEEN '".$start."' AND '".$end."'

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.