Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

MySql: Date range problem

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
AdrianSmithUK
Asked:
AdrianSmithUK
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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
 
AdrianSmithUKAuthor Commented:
What a Donkey!

Many thanks :@)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now