DSum Between Two Dates

kadara

Registered User.
Local time
Today, 13:41
Joined
Jun 19, 2010
Messages
43
I have a table with these fields:
Batch, QuantityIn, QuantityOut, DateIn, DateOut

I would like to display the difference of Sum of QuantityIn and Sum of QuantityOut (SumOfQuantityIn - SumOfQuantityOut) for a period (between DateIn and DateOut) for a single Batch in a TextBox.
Please help.

Thanks
 
Code:
Batch, QuantityIn, QuantityOut, DateIn, DateOut
... is poorly designed because it stores two discrete pieces of information in the same record. The event of some quantity arriving is distinct from the event of some quantity leaving. These might be different amounts on different days and would therefore be far more efficiently stored in different records.
I would create the record as follows ...
Code:
Batch, Quantity, Date
... and if it's in, Quantity is postive, and if it's out, Quantity is negative. Then you can simply sum Quantity for a particular Batch between two Date and you'd be done.
Cheers,
 

Users who are viewing this thread

Back
Top Bottom