Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySql: Date range problem

Posted on 2011-03-14
2
Medium Priority
?
403 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 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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