FoxSoft Calgary User Group - Puzzles

FoxSoft Calgary Puzzle Two

Home

Training

Member Solutions

Code Samples

Puzzles

FoxPro Links

Description:

People with accounting systems might find this problem interesting as it deals with date and time calculations. It deals with weekly sales analysis when your week ending day is dynamic. Some companies may end their week on a Friday, others on a Saturday.

So, given some sales data and a week ending day, produce sales summaries.
Here is a bit of code to create and populate a sales table:

Listing 1

CREATE TABLE Sales ;
( ;
salesdate DATETIME NOT NULL, ;
qty INTEGER NOT NULL ;
)

SET DATE YMD
INSERT INTO Sales VALUES({^2001/12/03}, 10)
INSERT INTO Sales VALUES({^2001/12/07}, 11)
INSERT INTO Sales VALUES({^2001/12/10}, 6)
INSERT INTO Sales VALUES({^2001/12/11}, 21)
INSERT INTO Sales VALUES({^2001/12/15}, 3)

Listing 2

Now, if you use Saturday as a week ending date, you should get results like this:

WEEK_END QTY
12/08/01 21
12/15/01 30

Listing 3

IF however, your week ending day is a Friday, you should get these results: WEEK_END QTY
12/07/01 21
12/14/01 27
12/21/01 3


There are some interesting and different ways to solve this problem. See if you can find some!

Web Master

     

Copyright © 2003 FoxSoft Calgary. All rights reserved.