Jump to content

Count range of date entries


reakt

Recommended Posts

Hi Guys

 

I have a datetime field in my database which is updated when a user loads a particular page. What I want to do is create a graph showing how many users hit that page each day for a range of dates. The only way I can think of to do this is to increment through each date in the range, counting how many matches in the database for each date.

 

1. Is there a better (more efficient) way to do this, considering that on some days there will be no matches?

 

2. I'm trying to count like this:

$date = date('Y/m/d');
$sql = "SELECT COUNT(*) FROM MailMerge WHERE landed= '$date';";

but I get "Data type mismatch in criteria expression". I guess I have to format the date somehow so MS SQL knows how to match it? Here is how I'm storing my dates:

$now = date('Y/m/d');
$sql = "UPDATE MailMerge SET landed = '$now' WHERE membership = '$membership';";

 

Any help would be appreciated.

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.