Source language: Translate to:

Age from date

General questions about NeoBook

Moderator: Neosoft Support

Age from date

Postby stu » Wed Aug 19, 2015 4:25 pm

Hi, I'm trying to come up with a formula to calculate the age of a person according to the date of birth, to be honest I think I can live without this but I dunno, using TSQL in the past I have used SELECT DATEDIFF(hour,@Param1,GETDATE())/8766 AS AgeTrunc and I was also taking a closer look at something like this: http://mathforum.org/library/drmath/view/59234.html

Is there a easier or better way of doing the same in Neobook?

Regards.
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Age from date

Postby AsleyCruz » Wed Aug 19, 2015 5:17 pm

Hi stu_
I used a VBScript to get the age from age.
Hope this code helps:

No plugins needed!

Code: Select all
Birthday = "[%1]"
Result = DateDiff("D",Birthday,Date)
TrueAge = Result / 365
TrueAge = Left(TrueAge,2)
publication.nbSetVar "[%2]", TrueAge


[%1] enter the birthday
[%2] variable to store the age

Regards_
Last edited by AsleyCruz on Wed Aug 19, 2015 5:37 pm, edited 2 times in total.
AsleyCruz
Freelancer - Graphic & Type Designer

FREE NEOBOOK APPS: See Website

.
User avatar
AsleyCruz
 
Posts: 108
Joined: Fri Sep 16, 2011 2:12 pm

Re: Age from date

Postby Ghatoo » Wed Aug 19, 2015 5:30 pm

Hola stu

Claro que hay una forma muy fácil, utiliza la función npYearsBetween del plugin nputil
Of course there is a very easy way, use the function npYearsBetween of the nputil plugin

Saludos
Jairo Moreno
Por favor no dejen morir a NeoBook! Please do not let NeoBook die!
Ghatoo
 
Posts: 4
Joined: Sun Feb 10, 2008 9:35 am

Re: Age from date

Postby stu » Thu Aug 20, 2015 3:43 am

Ghatoo wrote:Hola stu

Claro que hay una forma muy fácil, utiliza la función npYearsBetween del plugin nputil
Of course there is a very easy way, use the function npYearsBetween of the nputil plugin

Saludos
Jairo Moreno


AsleyCruz wrote:Hi stu_
I used a VBScript to get the age from age.
Hope this code helps:

No plugins needed!

Code: Select all
Birthday = "[%1]"
Result = DateDiff("D",Birthday,Date)
TrueAge = Result / 365
TrueAge = Left(TrueAge,2)
publication.nbSetVar "[%2]", TrueAge


[%1] enter the birthday
[%2] variable to store the age

Regards_


Only thing I'm thinking is, does these methods take leap years in account? Thanks for the replies! =)
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Age from date

Postby Gaev » Thu Aug 20, 2015 5:49 am

Stu:

NeoBook has built-in facilities for this ... from the Help file ...
Code: Select all
DateToNum "12/15/2004" "m/d/y" "[StartDate]"
DateToNum "[DateShort]" "Default" "[Today]"
Math "[Today]-[StartDate]" "0" "[Result]"
AlertBox "Answer" "It has been [Result] days since 12/15/2004"
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Age from date

Postby stu » Fri Aug 21, 2015 7:38 am

Gaev wrote:Stu:

NeoBook has built-in facilities for this ... from the Help file ...
Code: Select all
DateToNum "12/15/2004" "m/d/y" "[StartDate]"
DateToNum "[DateShort]" "Default" "[Today]"
Math "[Today]-[StartDate]" "0" "[Result]"
AlertBox "Answer" "It has been [Result] days since 12/15/2004"


Yeah, I wasnt sure about this method because of the Leap years but you know what, I'm just gonna drop that... Maybe its not even needed for the end product...

Thanks! :mrgreen:
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Age from date

Postby virger » Sat Aug 22, 2015 10:48 am

I use yhis way, i dont' have any problem. Maybe can help you.

Code: Select all
...BirthDay fmt 'day/month/year'
setvar "[FecNac]" "![d]/[m]/19[y]"
strparse "[FecNac]" "/" "[dmy]" "[x]"
math "[Year]-[dmy3]" "" "[Age]"
math "[MonthNum]-[dmy2]" "" "[Mes]"
if "[Mes]" "<" "0"
    math "[Age]-1" "" "[Age]"
endif

GdoSan/Dr.Sanchez--El Jubilado..Abril 2015
GdoSan/Dr.Sanchez--The Retired..April 2015
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 0 guests