valdemirs (valdemirs (AT) gmail (DOT) com) writes:
Quote:
I need get data from last 3 months,
but itīs shows me only January's data.
(Query doesnīt get data from november and december/2009) |
Have you verified that there is data from November and December 2009?
And does this data also include a time portion between 08:00 and 17:00?
And is the data type of the DateTime column datetime? Or is it something
else?
By the way, how many rows does your query return? The full 10000?
Quote:
SELECT TOP 10000 CONVERT(DateTime,
LTRIM(MONTH(DateTime)) + '/01/' + LTRIM(YEAR(DateTime)),
101) AS SummaryMonth, |
As lot easier way to write this is:
convert(datetime, convert(char(6), DateTime, 112) + '01')
--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx