Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How can i do to make the year difference from 2 dates? I need it to compute the age.
Marco
There is an "Age" function that does exactly this:
Age(timestamp, date_of_birth)
HIC
You should be able to use FABS(Year(Date1)-Year(Date2))
FABS will give you the absolute value so it doesn't matter which way around the dates are.
year(date1)-year(date2)+1 (( +1 depending what result you expect for same year (0 or 1)
or not that what you want? then specify more your requirements
Interval function will help you out
Interval(Date1-Date2,'DD')
Hi,
Try this:
DATA:
LOAD
*,
if(month(DeadDate)<month(BornDate),year(DeadDate)-year(BornDate)-1,year(DeadDate)-year(BornDate)) as "Age"
Inline [
BornDate, DeadDate
01/10/1950, 02/05/2015
01/01/1960, 03/08/2015
];
There is an "Age" function that does exactly this:
Age(timestamp, date_of_birth)
HIC
Ok with year we can approximate the age from now.
Thanks
Marco
If you need a more accurate age:
Floor((Date1 - Date2) / 365.25)
or
Ceil((Date1 - Date2) / 365.25)
or
Round((Date1 - Date2) / 365.25, 0.1)
use Interval() ,if u need u can specify format as well with the function.