Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
susopark
Contributor II
Contributor II

AGE() Function + Return of Months, Days and Hour

Hello,

I need the age of a TIMESTAMP, not only the year, but also including months, days and hour. How can I do that.

I need it in this specific format: 

susopark_0-1659003925475.png

And this is the script I've got so far:

TABLE:
LOAD * Inline [
ID, Name, Birthdate
1, John, 04/03/1998
2, Luke, 07/07/2003
3, Sarah, 30/03/1996
];

AGE:
NOCONCATENATE
LOAD
ID,
Name,
Birthdate,
Age(Now(), Birthdate) as Age
RESIDENT TABLE;

Drop table TABLE;

 

And this is the table result so far:

susopark_0-1659004172251.png

 

Labels (4)
1 Reply
edwin
Master II
Master II

first off you need to make sure you are using timestamp consistently.  for example:

edwin_0-1659009631503.png

next you need to use now() which is a time stamp.  this was run at about 8:01AM:  the diff between now() and your date will be a number in HOURS so it will just be a matter of getting the whole number and the fraction is converted into minutes and if you want more granularity, get the next set of fraction to convert it into secs. etc..

below i am displaying hours 

edwin_1-1659009712748.png