Click to See Complete Forum and Search --> : VB / SQL help


igadhia
May 29th, 2001, 04:02 AM
Hi all, I hope you can help me out. I am doing a bit of 'community service' for a struggling farm near here...I have created a database for him to record the cattle he has, (type, age, date bought etc etc) and we needs some reports from the system and I dont know the easiest way to do it...
1. user inputs a date. system outputs all cattle and the age on that date and other row data.
please provide any psudo code and any ideas you may have! thanks a lot !!

Cakkie
May 29th, 2001, 07:25 AM
This could be an example SQL statement. Note that you should make the date (here hardcoded 01/01/2001) variable by using parameterized queries. This assumes you are using Access
SELECT *, IIF(DateBorn > #01/01/2001#,'Not born yet', DateDiff("d",DateBorn,'01/01/2001') & ' days') AS Age
FROM Cows
WHERE DateDead > #01/01/2001#


This gives you all the data of all cows who weren't dead on 01/01/2001, plus the age in days. If a cows wasn't born yet, you will also see that.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook