Diferent in year dates

gonzy1981
Member Posts: 156
If i've two dates and i want to calculate the different in years, do you know to do it??
Thanks
Thanks
0
Comments
-
Can you give an example with the required result?0
-
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.0 -
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...0
-
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 know0 -
With duration is not possible.
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 wrong0 -
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...");
0 -
Hi
maybe for something simple you could doYears := DATE2DMY(TODAY,3) - DATE2DMY(BirthDate,3);
I recall seeing something about this in the Tips & Tricks
Hope this helps.
Albert0 -
Albertvh wrote:Hi
maybe for something simple you could doYears := 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...0 -
Hi
As I saidmaybe for something simple you could do
I found this link
Calculate Birthday - Age and Days
Edit: This is in the Tips & Tricks (URL didn't work)0 -
KISS please.
if calcdate('<CD+16Y>',BirthDate) < today then message('Older than Sixteen');
Not tested, so you may need to tweak it, but you should be able to fix it from there.
8><--- Should be "<" not greater.David Singleton0 -
kapamarou wrote:Let's say:
BithDate := SomeDate; birthDate16 := CALCDATE('+16Y',BithDate); ....
Opps I see you already suggested the same thing.
David Singleton0 -
Try this function.
CalcAge("Birth Date",WORKDATE);PROCEDURE CalcAge@1000000013(pStartDate@1000000000 : Date;pEndDate@1000000005 : Date) iYear : Integer; VAR YearNumber@1000000001 : Integer; BirthDay@1000000002 : Date; CompareDate@1000000003 : Date; ReturnNumber@1000000004 : Integer; BEGIN IF (pStartDate = 0D) OR (pEndDate = 0D) THEN EXIT(0); BirthDay := pStartDate; YearNumber := DATE2DMY(BirthDay,3); ReturnNumber := DATE2DMY(pEndDate,3) - YearNumber; IF (DATE2DMY(BirthDay,1) = 29) AND (DATE2DMY(BirthDay,2) = 2) THEN IF NOT ((DATE2DMY(pEndDate,1) = 29) AND (DATE2DMY(pEndDate,2) = 2)) THEN BirthDay := BirthDay -1; CompareDate := DMY2DATE(DATE2DMY(BirthDay,1),DATE2DMY(BirthDay,2),DATE2DMY(pEndDate,3)); IF (CompareDate - pEndDate) > 0 THEN ReturnNumber := ReturnNumber -1; iYear := ReturnNumber; END;
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions