Solved

MySql: Date range problem

Posted on 2011-03-14
2
400 Views
Last Modified: 2012-05-11
The query below returns some website data between two dates.

It worked fine until I added the line:

AND `_website` LIKE '%" . $site . "%'

Now it only shows results for the lower date and not the date range.

How should I rewrite it?
SELECT
min( _tStamp ) _tStamp,
`_website` ,
`_sid` ,
`_tag` ,
`_ip` ,
`_host` ,
`_town` ,
`_region` ,
`_country` ,
count( DISTINCT _id ) _totalPageViews ,
max(_serverLoad) _maxServerLoad ,
min(_serverLoad) _minServerLoad ,
max(_pageLoadTime) _maxPageLoadTime ,
min(_pageLoadTime) _minPageLoadTime ,
sum( `_pageVisitTime` ) _totalVisitTime,
sum(`_pageScrollSeconds`) _totalScrolls,
sum( _pageClicks )_totalPageClicks ,
`_screenWidth` ,
`_screenHeight`,
`_userAgent` ,
`_referrer`
FROM visitor_logs_version_c
WHERE _host IS NOT NULL 
AND `_website` LIKE '%" . $site . "%'
AND (`_tStamp` BETWEEN  '" . $fromDate . " 00:00:00' AND  '" . $fromDate . " 23:59:59')
GROUP BY _sid
ORDER BY _tStamp DESC

Open in new window

0
Comment
Question by:AdrianSmithUK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35129083
>Now it only shows results for the lower date and not the date range.

AND (`_tStamp` BETWEEN  '" . $fromDate . " 00:00:00' AND  '" .$fromDate . " 23:59:59')

shall be:

AND (`_tStamp` BETWEEN  '" . $fromDate . " 00:00:00' AND  '" . $toDate . " 23:59:59')
0
 

Author Closing Comment

by:AdrianSmithUK
ID: 35129212
What a Donkey!

Many thanks :@)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question