It does not display 6 lines, because 2012-08-31 accepted by the interpreter as 2012-08-31 00:00:00 AM . Since you want to see the data before the 31st day, including explicitly , indicate the time or request for the date of the next day.
An example of using the date of the next day
SELECT UserName FROM Users WHERE CreateTime >= '2012-08-30' AND CreateTime < '2012-09-01'
Example with time clearly marked
SELECT UserName FROM Users WHERE CreateTime >= '2012-08-30 00:00:00' AND CreateTime < '2012-09-31 23:59:59'
source share