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
https://forums.phpfreaks.com/topic/228767-count-range-of-date-entries/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.