Click here to Skip to main content
15,914,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all visitors
I have one report, in my report i want to show the sales amount of arrange of hours
EX:Hour____________________Amount
9-10____________________$454,564
10-11___________________$34,523

In my table i have only Date(09/01/2011 09:42:43) like this.
If i use hours(fieldname), it just show the hour only(9,10,11,....)
not arrage(9-10,10-11,,,,,,).
How can i do that?
Should i design in sql server or in Crystal report?
Best Regards,
Posted
Updated 5-Apr-11 21:08pm
v2

I think it's easier in SQL Sever. Try using this

SELECT DatePart(hour, hour) FROM Table WHERE hour is not null

and then group and do the rest with the amount.
Then just display the result in crystal report.
 
Share this answer
 
Using this should group by hour, where time_column represents your DateTime:

GROUP BY dateadd(hour, datediff(hour, 0, time_column), 0)
 
Share this answer
 
v2
And you can of course define the sort ordering also in Crystal if you like. This is handy if you for example need to use formulas for defining correct sorting.
 
Share this answer
 
Better way to create stored procedure for the same.
1) use temporary table and and store range value already.
2) use select query to update this table for amount value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900