Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

How can I calculate the age (in days) of a record given I have the creation date.

There is no "Date difference" (DateSub) function.

Using Date# does not work (If there is a difference between Date and Date#, I can not see it).

Using Today(1)-Num(Date(CreateDate)) {or Today(1)-Num#(Date#(CreateDate)) } does not work.

adding in Floor, etc. does not help.

It always shows as "-".

It seems as if CreateDate (which as a date hence a dual) will always be a date and so can not be subtracted from today.

There is networkdays (read as net work days) that does sort of what I want except I want to count weekend days also.

1 Solution

Accepted Solutions

Re: How can I calculate the age (in days) of a record given I have the creation date.

1st thing to check, is your date interpret correctly by Qlik Sense?

Why don’t my dates work?

Get the Dates Right

Once you have the fixed, Today(1) - Creation_Date should work. If for some reason it still doesn't work, please provide us with a sample so that we can help you better here.

Best,

Sunny

3 Replies

Re: How can I calculate the age (in days) of a record given I have the creation date.

1st thing to check, is your date interpret correctly by Qlik Sense?

Why don’t my dates work?

Get the Dates Right

Once you have the fixed, Today(1) - Creation_Date should work. If for some reason it still doesn't work, please provide us with a sample so that we can help you better here.

Best,

Sunny

MVP
MVP

Re: How can I calculate the age (in days) of a record given I have the creation date.

There is no "Date difference" (DateSub) function.

the date difference is just a math subtraction

this is the difference between today and the beginning of the year

today(1)  - MakeDate(2016)

maybe your CreateDate is not a date

and you need a format to interpret your CreateDate

Date#(CreateDate, 'herethedateformat')


https://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Scripting/InterpretationFunctions/date_...

Not applicable

Re: How can I calculate the age (in days) of a record given I have the creation date.

Thank you for your assistance.

The dates come from an SQL datebase (MQ SQL) .

CreatedDate is an SQL column of type datetime.

I also have [Created On] which is loaded from CreatedDate by  Date(CreatedDate, 'YYYY-MM-DD') as "Created On",

Based on what you said I decided to use [Created On] instead and that works.

I do not know why CreatedDate did not work, it displays as a date and time etc.

So I reverted back to what I did in the beginning Today(1)-CreatedDate and now that works.

To get whole days I added a floor, floor(Today(1)-CreatedDate) and that is working now.

Maybe I has some other error that I did not recognize in the very first attempt.

Thanks again.

Community Browser