MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 11th, 2013, 09:38 AM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 179 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 12 h 17 m 13 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
Trying to get a count between a range of dates

mysql> desc ClosedPeriodActivitySummary;
+-------------+--------------------------------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------------------------------+------+-----+-------------------+-------+
| FundId | int(11) | NO | MUL | NULL | |
| BegDate | date | NO | MUL | NULL | |
| EndDate | date | NO | MUL | NULL | |
| Category | enum('CASH','MARKET') | YES | MUL | NULL | |
| ItemName | varchar(32) | YES | MUL | NULL | |
| Amount | decimal(16,2) | YES | | NULL | |
| Direction | enum('INFLOW','OUTFLOW','NET-VALUE') | YES | MUL | NULL | |
| LastUpdated | timestamp | NO | | CURRENT_TIMESTAMP | |
+-------------+--------------------------------------+------+-----+-------------------+-------+


Then I do the following select of:

select count(*) from ClosedPeriodActivitySummary where BegDate < now() and BegDate > '2013-01-11';

*** Count(*) 1313

mysql> show table status like 'ClosedPeriodActivitySummary';
+-----------------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+-----------------------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+-----------------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+-----------------------+
| ClosedPeriodActivitySummary | InnoDB | 10 | Compact | 84921 | 105 | 8929280 | 0 | 21069824 | 0 | NULL | 2012-05-18 15:20:24 | NULL | NULL | latin1_swedish_ci | NULL | | InnoDB free: 15360 kB |
+-----------------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+-----------------------+
1 row in set (0.42 sec)


*** Avg_row_length 89

NOW that is in BYTES...so to get the size of a month's of data 1313 x 89 = 116857 bytes which is 0.11144 MB

ISSUE: I wanted to test for a different time period, so I wrote a different select query and am getting a error:

mysql> select count(*) from ClosedPeriodActivitySummary where BegDate between '2013-01-01' and BegDate '2013-01-31';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2013-01-31'' at line 1


So what am I doing wrong here...

I am using Community version 5.0.51a MySQL

I am just trying to obtain the count for the number of rows added in this table ClosedPeriodActivitySummary for the period of 2013-01-01 to 2013-01-31 how do I do that in syntax for my version of MySQL?

Reply With Quote
  #2  
Old February 11th, 2013, 10:47 AM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 179 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 12 h 17 m 13 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
I figured it out...

mysql> select count(*) from ClosedPeriodActivitySummary where BegDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 3120 |
+----------+
1 row in set (0.03 sec)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Trying to get a count between a range of dates

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap