Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating age of animals

Status
Not open for further replies.

gilly7

Technical User
Dec 5, 2003
1
IE
Hello,

Im just wondering if anyone can come up with a solution to calculate the age of dairy cows using the animals Date Of birth and output the age in months rather than years. Also when an amimal reaches 30 months is there any way to automatically move them to a new table as animals over 30 months will be 99% slaughtered. Its a project for my neighbours farm and it would be great if anyone could help. Thanks. Ronan
 
I suspect it depends on the dev tool you're using..... care to share that bit of info?
 
The age is simply calculated with the DateDiff function
Code:
   CowAge = DateDiff ( "m", DateOfBirth, Date() )
You will need to use some procedural code to move the "over 30 month" animals.
Code:
      SQL = "INSERT INTO tblOver30 " & _
            "Select * From tblAllCows " & _
            "Where DateDiff ( "m", DateOfBirth, Date() ) >= 30 "

      Conn.EXECUTE SQL

      SQL = "Delete * From tblAllCows " ^ & _
            "Where DateDiff ( "m", DateOfBirth, Date() ) >= 30 "

      Conn.EXECUTE SQL

      etc.
This solution involves functions from VBA. If you are using some other DBMS then, as 1oldfoxman said, you will need to adjust for the language constructs available on your system.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top