Solved

MySql: Date range problem

Posted on 2011-03-14
2
398 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 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