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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating weeks

Status
Not open for further replies.

calabama

Programmer
Feb 19, 2001
180
0
0
US
Hello ,

I want to use todays date and a date of birth to calculate how many weeks old a dog is.

Thanks

In the begining
Let us first assume that there was nothing to begin with.
 
Date calculations are not that difficult, for FM a date is a number.

Just don-t use the 'Today', but the Get(CurrentDate) function.

Get(CurrentDate) - date of birth will give you the days between those two dates.
This will give you the days 'between', so you will have to add 1 day for an 'age', depend how your definition for age is.

To get the weeks you have to devide by 7 (7 days in a week)

This will give you a clumsy number x,yyyy.

So, we take the integer in one field and the modulo in an other field:

Int((Get(CurrentDate)-date of birth)/7)for the rest days and

Mod( (Get(CurrentDate - date date of birth), 7)for the week(s)

Play with the +1 to get close to your definition of age and make sure the calculation result is number, unstored.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top