I have to calculate the age of one person, i have two dates:
- First date, the date that person was born
- Secund date, Workdate.
And i want to know if that person has more of 16 years.
You could use a Duration datatype to be more accurate or you could Subtract dateA from dateB to get the difference in days and the divide by the days per year... Something like that...
I'm going to try with duration.
But the problem with the other option is that, some years have less/more days then others and if i divide by 365 the age is not exacty.
I think that there is a Nav's rutine that do it, but a I don't know
Do you know, how to calculate the days into two dates?? i'll try to do it dividing into 365, because i don't find any rutine that give me in years diferent in dates.
Because i subtract two dates, but the subtract return me in a datatype in integer (Nav can't put a datatype 'date' or 'datetime') that has a value wrong
Although it could work and you could look for leap years then try a different approach.
Let's say:
BithDate := SomeDate;
birthDate16 := CALCDATE('+16Y',BithDate);
IF birthDate16 = TODAY THEN
MESSAGE("The Party Is On");
IF birthDate > TODAY THEN
MESSAGE("You must buy a present");
IF birthDate16 < TODAY THEN
MESSAGE("Nice Memory...");
Years := DATE2DMY(TODAY,3) - DATE2DMY(BirthDate,3);
I recall seeing something about this in the Tips & Tricks
Hope this helps.
Albert
This way you subtract years. If the birthday is on December and TODAY is on January then the age will be wrong. It will give for example 16, but the actual age will be 15 and a month...
Comments
- First date, the date that person was born
- Secund date, Workdate.
And i want to know if that person has more of 16 years.
But the problem with the other option is that, some years have less/more days then others and if i divide by 365 the age is not exacty.
I think that there is a Nav's rutine that do it, but a I don't know
Do you know, how to calculate the days into two dates?? i'll try to do it dividing into 365, because i don't find any rutine that give me in years diferent in dates.
Because i subtract two dates, but the subtract return me in a datatype in integer (Nav can't put a datatype 'date' or 'datetime') that has a value wrong
Let's say:
maybe for something simple you could do
I recall seeing something about this in the Tips & Tricks
Hope this helps.
Albert
This way you subtract years. If the birthday is on December and TODAY is on January then the age will be wrong. It will give for example 16, but the actual age will be 15 and a month...
As I said
I found this link
Calculate Birthday - Age and Days
Edit: This is in the Tips & Tricks (URL didn't work)
Not tested, so you may need to tweak it, but you should be able to fix it from there.
8><--- Should be "<" not greater.
Opps I see you already suggested the same thing.
CalcAge("Birth Date",WORKDATE);