CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VB / SQL help

  1. #1
    Join Date
    May 2001
    Posts
    6

    VB / SQL help

    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 !!


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: VB / SQL help

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured