Wrox Programmer Forums > C# puzzle for date ranges
 |
 C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
 Welcome to the p2p.wrox.com Forums. You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com

October 16th, 2008, 07:49 AM
 navjot Registered User Join Date: Oct 2008 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts
puzzle for date ranges

hi all,

my problem is i have data like below(dates are in dd\mm\yyyy format)

start_date end_date fruits_eaten per_day_fruit_eaten

5/5/2008 14/5/2008 40 40/10 = 4
12/5/2008 21/5/2008 30 30/10 = 3
20/5/2008 30/5/208 55 55/11 = 5

i want to calculate above data like below

for the dates between 10/5/2008 and 25/5/2008 total fruits eaten are :

10/5/2008 = 4
11/5/2008 = 4
12/5/2008 = 4 + 3
13/5/2008 = 4 + 3
14/5/2008 = 4 + 3
15/5/2008 = 3
16/5/2008 = 3
17/5/2008 = 3
18/5/2008 = 3
19/5/2008 = 3
20/5/2008 = 3 + 5
21/5/2008 = 3 + 5
22/5/2008 = 5
23/5/2008 = 5
24/5/2008 = 5
25/5/2008 = 5

please help me solve this puzzle as it is driving me nuts !! i want to solve it in c# but logics are also welcomed

October 16th, 2008, 02:21 PM
 Old Pedant Friend of Wrox Join Date: Jun 2008 Posts: 1,649 Thanks: 3 Thanked 141 Times in 140 Posts

Homework???

If the data is in a database, then you do *NOT* want to solve it with C# code. You want and need to solve it with SQL code and SQL logic. (Which, incidentally, will be easier than solving it with C# code and logic.)

But in any case, we should not do your homework for you. How can you learn if you don't at least *TRY* to write the code yourself.

Write the code as far as you can. Whether in C# or SQL. Get at least *some* answers to start coming out, even if they aren't right. *THEN* show your code and ask for help again.

 Similar Threads Thread Thread Starter Forum Replies Last Post A small puzzle marianeeli C++ Programming 9 September 5th, 2006 12:02 AM Date Ranges nbuckwheat Access 1 December 12th, 2005 12:45 PM date ranges yuqlin BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 December 23rd, 2004 05:23 PM Query regarding Date Ranges spraveens SQL Language 7 January 13th, 2004 08:11 AM Query Returning Date Ranges rstelma SQL Server 2000 4 October 28th, 2003 08:57 PM